Last active
August 29, 2015 14:01
-
-
Save Ahrengot/8f1b6a84a91f8dc8fbee 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
| define ["underscore", "gsap"], (_) -> | |
| class ParallaxFun | |
| constructor: -> | |
| @center = { x: window.innerWidth >> 1, y: window.innnerHeight >> 1 } | |
| @updated = no | |
| $(document).on( "mousemove", @updateMousePos ); | |
| setTimeout( @doParallax, 1000 ) | |
| updateMousePos: (e) => | |
| @center.x = e.clientX | |
| @center.y = e.clientY | |
| @updated = yes | |
| doParallax: => | |
| requestAnimationFrame( @doParallax ) | |
| return unless @updated | |
| @updated = no | |
| # Run code |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment