Scrolling can be detected by binding scroll event to window. To determine the scroll direction we need to compare the present scroll position with previous scroll position.

Program Flow

  1. Compare window.pageYOffset with lastScrollPosition - If it is greater the scroll direction is down or the scroll direction is up
  2. Store present window.pageYOffset to lastScrollPosition 


$scope.lastScrollTop = 0;
$scope.direction = "";
angular.element($window).bind("scroll", function() {
      $ = window.pageYOffset;
      if ($ > $scope.lastScrollTop) {
          $scope.direction = "down";
      } else {
          $scope.direction = "up";

      $scope.lastScrollTop = $;

1 comment:

  1. How to determine the direction of scroll using angularJS. Scrolling can be detected on window events, Leaving things for essay writing not looking good you have a chance to make best dissertation help things perfect. Ever trying to determine the directions for events.



Follow this blog by Email

Popular Posts