Skip to content

Instantly share code, notes, and snippets.

@weisk
Created May 5, 2015 15:06
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 weisk/ab2f263641edfe08fe45 to your computer and use it in GitHub Desktop.
Save weisk/ab2f263641edfe08fe45 to your computer and use it in GitHub Desktop.
Smooth Scrolling
app.run ($rootScope, $state, SessionService, $window) ->
$rootScope.$state = $state
$rootScope.logout = -> SessionService.logout true
win = $($window)
scrollTime = 0.3
scrollDistance = 200
win.on 'mousewheel DOMMouseScroll', (evt) ->
evt.preventDefault()
delta = evt.originalEvent.wheelDelta/120 || -evt.originalEvent.detail/3
scrollTop = win.scrollTop()
finalScroll = scrollTop - parseInt(delta * scrollDistance)
TweenMax.to win, scrollTime,
scrollTo:
y: finalScroll
autoKill: true
ease: Power1.easeOut
overwrite: 5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment