angular-ui / ui-scroll

Unlimited bidirectional scrolling over a limited element buffer for AngularJS applications
http://angular-ui.github.io/ui-scroll/demo/
MIT License
327 stars 107 forks source link

$apply already in progress #179

Closed real-artswan closed 6 years ago

real-artswan commented 6 years ago

Running demo "insideComponent" I get error when clicking on items Error: [$rootScope:inprog] $apply already in progress http://errors.angularjs.org/1.5.7/$rootScope/inprog?p0=%24apply minErr/<@https://ajax.googleapis.com/ajax/libs/angularjs/1.5.7/angular.js:68:12 beginPhase@https://ajax.googleapis.com/ajax/libs/angularjs/1.5.7/angular.js:17804:15 $digest@https://ajax.googleapis.com/ajax/libs/angularjs/1.5.7/angular.js:17234:9 adjustBuffer@file:///home/artem/DEVELOPMENT/ng-scroll-test/node_modules/angular-ui-scroll/dist/ui-scroll.js:1469:26 applyUpdates@file:///home/artem/DEVELOPMENT/ng-scroll-test/node_modules/angular-ui-scroll/dist/ui-scroll.js:248:7 update@file:///home/artem/DEVELOPMENT/ng-scroll-test/insideComponent.js:24:14 fn@https://ajax.googleapis.com/ajax/libs/angularjs/1.5.7/angular.js line 14605 > Function:4:420 expensiveCheckFn@https://ajax.googleapis.com/ajax/libs/angularjs/1.5.7/angular.js:15694:18 callback@https://ajax.googleapis.com/ajax/libs/angularjs/1.5.7/angular.js:25622:17 $eval@https://ajax.googleapis.com/ajax/libs/angularjs/1.5.7/angular.js:17444:16 $apply@https://ajax.googleapis.com/ajax/libs/angularjs/1.5.7/angular.js:17544:20 ngEventHandler/<@https://ajax.googleapis.com/ajax/libs/angularjs/1.5.7/angular.js:25627:17 defaultHandlerWrapper@https://ajax.googleapis.com/ajax/libs/angularjs/1.5.7/angular.js:3488:3 eventHandler@https://ajax.googleapis.com/ajax/libs/angularjs/1.5.7/angular.js:3476:9

dhilt commented 6 years ago

@real-artswan What version of ui-scroll are you using? It's the typical v1.6.2/v1.6.3 error. If it's so, I would recommend to update in to v1.7.0-rc.2.

real-artswan commented 6 years ago

@dhilt It is the version installed by npm. It says "version": "1.7.0-rc.2"

real-artswan commented 6 years ago

By the way, with the latest AngularJS 1.6.6 I get different error $apply already in progress

dhilt commented 6 years ago

@real-artswan Ok, I tried to reproduce it locally and I can't. Should I take some specific steps to get that error or just run the demo which is in the repository? Also your Browser/OS versions and maybe other environment information could be helpful.

ckuhar-broadsoft commented 6 years ago

The issue I saw was that angular was checking if an apply is taking place on rootScope ($rootScope.$$phase), whereas in ui-scroll, it was checking scope.

I had to comment out this line to get things to work in our case:

function adjustBuffer(rid) { if (!rid) { // dismiss pending requests pending = []; rid = ++ridActual; } var updates = updateDOM();

  // We need the item bindings to be processed before we can do adjustment
  //!$scope.$$phase && $scope.$digest();  << offending line

========== version ==========

dhilt commented 6 years ago

@ckuhar-broadsoft Thanks for report! With the help of @zacronos the fix for exact this issue is already in master and will be included in the nearest release. While you can download and use latest distributive from master: https://github.com/angular-ui/ui-scroll/tree/41d25629287879c445e278c80cb622ca9f1d7349/dist.

dhilt commented 6 years ago

@ckuhar-broadsoft Since the issue is critical, I decided to make an interim release, 1.7.0-rc.3. It should be already available via npm.