Skip to content

Instantly share code, notes, and snippets.

@yairEO
Created October 19, 2013 18:09
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 yairEO/7059388 to your computer and use it in GitHub Desktop.
Save yairEO/7059388 to your computer and use it in GitHub Desktop.
move things in paralex on mouse move
// 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