Created
October 19, 2013 18:09
-
-
Save yairEO/7059388 to your computer and use it in GitHub Desktop.
move things in paralex on mouse move
This file contains 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
// mouse move animations | |
$('.container').on('mousemove', moveSquares); | |
function moveSquares(e){ | |
var mousex = (e.pageX - (e.currentTarget.clientWidth/2)) / e.currentTarget.clientWidth; | |
for( i in squares ){ | |
if( i < 6) | |
squares[i].style.cssText = transform + ': translateX('+ Math.ceil(mousex*55) +'px)'; | |
if( i >= 6 && i < 10) | |
squares[i].style.cssText = transform + ': translateX('+ Math.ceil(mousex*20) +'px)'; | |
if( i >= 10 ) | |
squares[i].style.cssText = transform + ': translateX('+ Math.ceil(mousex*10) +'px)'; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment