0

i have implement infinite scroll in out website but it is fire twice time after 1 time scroll.i have used infinite-scroll-disabled but its not working for me.tell me anyone how to fix scrolling issue?

  $scope.loadMore = function() {
    $scope.infiniteScorllStatus  = true;
     $scope.adv_offset ++;

    if($scope.infiniteScorllStatus) {
       $http.get(APP.service.userPost + 
            '?user_id=' + $rootScope.currentUserID + '&limit=' +  $scope.limit + '&offset=' +  $scope.offset +  '&adv_offset=' + $scope.adv_offset).then(function(response) {
        if(response.data.status == 1) {

          //
          $scope.shots =  response.data.response;
          $scope.offset =  $scope.shots.length;
          $scope.limit = $scope.offset + 6;
          $scope.infiniteScorllStatus  = false; 
        }
      });
    }
}


<div infinite-scroll="loadMore()" infinite-scroll-distance="0" 
     infinite-scroll-disabled="infiniteScorllStatus" >
    <section class=" masonry-item" ng-repeat="item in data">
      {{item.name}}
    </section>
 </div>

I have tried above code but its not working for me tell me whats the wrong in my code?

Vikasdeep Singh
  • 20,983
  • 15
  • 78
  • 104
Kapil Soni
  • 1,003
  • 2
  • 15
  • 37

1 Answers1

0

return from function if your $scope.infiniteScorllStatus is true.

 $scope.loadMore = function() {
    if ( $scope.infiniteScorllStatus)
        return;
    $scope.infiniteScorllStatus  = true;
     $scope.adv_offset ++;

    if($scope.infiniteScorllStatus) {
       $http.get(APP.service.userPost + 
            '?user_id=' + $rootScope.currentUserID + '&limit=' +  $scope.limit + '&offset=' +  $scope.offset +  '&adv_offset=' + $scope.adv_offset).then(function(response) {
        $scope.infiniteScorllStatus  = false; 
        if(response.data.status == 1) {

          //
          $scope.shots =  response.data.response;
          $scope.offset =  $scope.shots.length;
          $scope.limit = $scope.offset + 6;

        }
      });
    }
}