Skip to content

Instantly share code, notes, and snippets.

@stryju

stryju/scrollfix.js

Created Mar 28, 2014
Embed
What would you like to do?
var scrollPromise;
function scrollFix ( $window, $timeout, $delegate ) {
function smoothScroll() {
var y = $window.scrollY;
if ( y < 5 ) {
$window.scrollTo( 0, 0 );
return false;
}
$window.scrollTo( 0, y * 0.9 );
scrollPromise = $timeout( smoothScroll, 0, false );
}
return function ( view ) {
if ( scrollPromise ) {
$timeout.cancel( scrollPromise );
}
smoothScroll();
};
}
$provide.decorator( '$uiViewScroll', [ '$window', '$timeout', '$delegate', scrollFix ]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment