-
-
Save anteprimorac/5ba71412f93db35ca83e to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| ;( 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