Skip to content

Instantly share code, notes, and snippets.

@stryju
Created March 28, 2014 16:55
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 stryju/9837530 to your computer and use it in GitHub Desktop.
Save stryju/9837530 to your computer and use it in GitHub Desktop.
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