Skip to content

Instantly share code, notes, and snippets.

@Ahrengot
Last active August 29, 2015 14:01
Show Gist options
  • Select an option

  • Save Ahrengot/8f1b6a84a91f8dc8fbee to your computer and use it in GitHub Desktop.

Select an option

Save Ahrengot/8f1b6a84a91f8dc8fbee to your computer and use it in GitHub Desktop.
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