Skip to content

Instantly share code, notes, and snippets.

@pawellenart
Created June 15, 2012 13:45
Show Gist options
  • Save pawellenart/2936547 to your computer and use it in GitHub Desktop.
Save pawellenart/2936547 to your computer and use it in GitHub Desktop.
var fsButton = document.getElementById('fsbutton'),
container = document.getElementById('canvas');
if (window.fullScreenApi.supportsFullScreen) {
fsButton.style.display = 'block';
fsButton.addEventListener('click', function() {
if (fsButton.className == 'fs-off') {
window.fullScreenApi.requestFullScreen(container);
} else {
window.fullScreenApi.cancelFullScreen(container);
}
}, true);
container.addEventListener(fullScreenApi.fullScreenEventName, function() {
if (fullScreenApi.isFullScreen()) {
container.style.width = container.style.height = '100%';
fsButton.className = 'fs-on';
} else {
fsButton.className = 'fs-off';
}
}, true);
} else {
// no fullscreen support - do nothing
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment