Skip to content

Instantly share code, notes, and snippets.

@anikets
Last active August 29, 2015 14:03
Show Gist options
  • Save anikets/8b8ce40fbcb4ab5d138f to your computer and use it in GitHub Desktop.
Save anikets/8b8ce40fbcb4ab5d138f to your computer and use it in GitHub Desktop.
Behaviour for Jalousie Window
var xc, yc; // X and Y coordinates of the mouse pointer.
// Change perspective origin as the mouse pointer moves.
document.body.addEventListener( 'mousemove', function( event ) {
// Chrome returns event.x and event.y whereas Firefox returns
// eventclientX and eventClientY.
'x' in event ? xc = event.x : xc = event.clientX;
'y' in event ? yc = event.y : yc = event.clientY;
document.body.setAttribute('style', 'perspective-origin:' + xc + 'px ' + yc + 'px;' + '-webkit-perspective-origin-x:' + xc + 'px; -webkit-perspective-origin-y:' + yc + 'px' );
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment