Created
March 12, 2013 03:42
-
-
Save jennschiffer/5140138 to your computer and use it in GitHub Desktop.
a canvas that fills the whole browser window
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(document).ready(function(){ | |
// create canvas the size of the window | |
var canvasHeight = $(window).height(); | |
var canvasWidth = $(window).width(); | |
$('body').prepend('<canvas id="canvas" width="'+ canvasWidth +'" height="'+ canvasHeight + '" style="cursor:crosshair;">Your browser doesn\'t support canvas. Boo-hiss.</canvas>'); | |
// resize canvas if window size changes - I particularly don't like this, but whatevs floats yo boats... | |
$(window).resize(function() { | |
var canvasHeight = $(window).height(); | |
var canvasWidth = $(window).width(); | |
$('#canvas').attr('width', canvasWidth).attr('height', canvasHeight); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment