Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
;( function( $ ) {
var $background,
mouse = {
x: 0, // Current x-axis position of mouse
y: 0 // Current y-axis position of mouse
};
$( document ).on( 'mousemove', function( event ) {
mouse.x = event.clientX || event.pageX;
mouse.y = event.clientY || event.pageY;
if ( $background && $background.length )
$background.css( {
'transform': 'translate( ' + ( ( $( window ).width() / 2 - mouse.x ) / $( window ).width() * 100 ) + 'px, ' + ( ( $( window ).height() / 2 - mouse.y ) / $( window ).height() * 100 ) + 'px )'
} );
} );
$( document ).on( 'ready', function() {
$background = $( '.background-wrapper' );
} );
} ) ( jQuery )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.