Created
May 5, 2015 15:06
-
-
Save weisk/ab2f263641edfe08fe45 to your computer and use it in GitHub Desktop.
Smooth Scrolling
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
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