Skip to content

Instantly share code, notes, and snippets.

@rudiedirkx
Created March 1, 2015 18:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rudiedirkx/719f3594507d37d51412 to your computer and use it in GitHub Desktop.
Save rudiedirkx/719f3594507d37d51412 to your computer and use it in GitHub Desktop.
(function() {
var _x, _y;
function scroll(video) {
var x = _x / innerWidth;
var dx = 1.1 * (-innerWidth/2*x + innerWidth/4);
video.style.marginLeft = Math.round(Math.max(-innerWidth/4, Math.min(innerWidth/4, dx))) + 'px';
var y = _y / innerHeight;
var dy = 1.3 * (-innerHeight/2*y + innerHeight/4);
video.style.marginTop = Math.round(dy) + 'px';
}
document.addEventListener('keydown', function(e) {
if ( e.keyCode == 90 ) {
var video = document.querySelector(':-webkit-full-screen video');
if ( video ) {
var zoom = video.classList.toggle('zoom15');
if ( zoom ) {
scroll(video);
}
else {
video.style.marginLeft = video.style.marginTop = '';
}
}
}
});
document.addEventListener('mousemove', function(e) {
_x = e.x, _y = e.y;
var video = document.querySelector(':-webkit-full-screen video.zoom15');
if ( video ) {
scroll(video);
}
});
})();
void(0);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment