=g.hunkSize||0===m.vsRepeat.startIndex&&0!==T?u=!0:(Math.abs(m.vsRepeat.endIndex-C)>=g.hunkSize||m.vsRepeat.endIndex===R&&C!==R)&&(u=!0):u=m.vsRepeat.startIndex!==T||m.vsRepeat.endIndex!==C),u){var p;m[L]=y.slice(m.vsRepeat.startIndex,m.vsRepeat.endIndex),m.$emit("vsRepeatInnerCollectionUpdated",m.vsRepeat.startIndex,m.vsRepeat.endIndex,T,C),g.scrolledToEnd&&(p=y.length-g.scrolledToEndOffset,(m.vsRepeat.endIndex>=p&&Cm.vsRepeat.startIndex&&m.$eval(g.scrolledToBeginning)),T=m.vsRepeat.startIndex,C=m.vsRepeat.endIndex;var v=m.vsRepeat.sizesCumulative[m.vsRepeat.startIndex]+g.offsetBefore,f=m.vsRepeat.sizesCumulative[m.vsRepeat.startIndex+m[L].length]+g.offsetBefore,h=m.vsRepeat.totalSize;z.css(M(),v+"px"),$.css(M(),h-f+"px")}return u}g.horizontal?(z.css("height","100%"),$.css("height","100%")):(z.css("width","100%"),$.css("width","100%")),e.vsRepeatOptions&&m.$watchCollection(e.vsRepeatOptions,function(e){var t=_extends({},g,e);JSON.stringify(t)!==JSON.stringify(g)&&(Object.assign(g,e),r(g),E())}),m.$watchCollection(N,function(){var e=0\n\t \t.vs-repeat-debug-element {\n top: 50%;\n left: 0;\n right: 0;\n height: 1px;\n background: red;\n z-index: 99999999;\n box-shadow: 0 0 20px red;\n }\n\n .vs-repeat-debug-element + .vs-repeat-debug-element {\n display: none;\n }\n '),"undefined"!=typeof module&&module.exports&&(module.exports=e.name)}(window,window.angular);
\ No newline at end of file
+function _toConsumableArray(e){if(Array.isArray(e)){for(var t=0,n=new Array(e.length);t'+o+">"),b=U.element("<"+o+' class="vs-repeat-after-content">'+o+">"),I=null===R.size,w=R.scrollParent?"window"===R.scrollParent?U.element(Y):X.call(z,R.scrollParent):z,S=R.horizontal?"clientWidth":"clientHeight",a=R.horizontal?"offsetWidth":"offsetHeight",T=R.horizontal?"scrollWidth":"scrollHeight",A=R.horizontal?"scrollLeft":"scrollTop";if((g.vsRepeat.totalSize=0)===w.length)throw"Specified scroll parent selector did not match any element";if(g.vsRepeat.$scrollParent=w,g.vsRepeat.sizesCumulative=[],R.debug){var s="window"===R.scrollParent?U.element(document.body):w,i=U.element('');i.css("position","window"===R.scrollParent?"fixed":"absolute"),s.append(i),g.$on("$destroy",function(){i.remove()})}var C,O,M,_,l,d=K(w[0],S)||50;function c(){!$||$.length<1?(g[q]=[],x=0,g.vsRepeat.sizesCumulative=[0]):(x=$.length,R.size?u():p()),h()}function u(){var n=0t?P(e,t,n,a,o+1):P(e,t,a,r,o+1)}return[t>e[r]?r:n,t=R.hunkSize||0===g.vsRepeat.startIndex&&0!==C?u=!0:(Math.abs(g.vsRepeat.endIndex-O)>=R.hunkSize||g.vsRepeat.endIndex===x&&O!==x)&&(u=!0):u=g.vsRepeat.startIndex!==C||g.vsRepeat.endIndex!==O),u){var p;g[q]=$.slice(g.vsRepeat.startIndex,g.vsRepeat.endIndex),g.$emit("vsRepeatInnerCollectionUpdated",g.vsRepeat.startIndex,g.vsRepeat.endIndex,C,O),R.scrolledToEnd&&(p=$.length-R.scrolledToEndOffset,(g.vsRepeat.endIndex>=p&&Og.vsRepeat.startIndex&&g.$eval(R.scrolledToBeginning)),C=g.vsRepeat.startIndex,O=g.vsRepeat.endIndex;var v=g.vsRepeat.sizesCumulative[g.vsRepeat.startIndex]+R.offsetBefore,f=g.vsRepeat.sizesCumulative[g.vsRepeat.startIndex+g[q].length]+R.offsetBefore,h=g.vsRepeat.totalSize;y.css(B(),v+"px"),b.css(B(),h-f+"px")}return u}R.horizontal?(y.css("height","100%"),b.css("height","100%")):(y.css("width","100%"),b.css("width","100%")),e.vsRepeatOptions&&g.$watchCollection(e.vsRepeatOptions,function(e){var t=_extends({},R,e);JSON.stringify(t)!==JSON.stringify(R)&&(Object.assign(R,e),n(R),h())}),g.$watchCollection(N,function(){var e=0\n\t \t.vs-repeat-debug-element {\n top: 50%;\n left: 0;\n right: 0;\n height: 1px;\n background: red;\n z-index: 99999999;\n box-shadow: 0 0 20px red;\n }\n\n .vs-repeat-debug-element + .vs-repeat-debug-element {\n display: none;\n }\n '),"undefined"!=typeof module&&module.exports&&(module.exports=e.name)}(window,window.angular);
\ No newline at end of file
diff --git a/gulpfile.babel.js b/gulpfile.babel.js
index fd37070..a77a33d 100644
--- a/gulpfile.babel.js
+++ b/gulpfile.babel.js
@@ -5,12 +5,7 @@ import rename from 'gulp-rename';
import clean from 'gulp-clean';
import { Server } from 'karma';
-gulp.task('clean', () =>
- gulp.src('dist', { read: false })
- .pipe(clean())
-);
-
-gulp.task('babel', ['clean'], () =>
+gulp.task('babel', () =>
gulp.src('src/angular-vs-repeat.js')
.pipe(babel())
.pipe(gulp.dest('dist'))
@@ -40,6 +35,6 @@ gulp.task('karma-travis', ['build'], (done) => {
}, done).start();
});
-gulp.task('build', ['clean', 'babel', 'min']);
+gulp.task('build', ['babel', 'min']);
gulp.task('test', ['build', 'karma']);
gulp.task('travis', ['build', 'karma-travis']);
diff --git a/src/angular-vs-repeat.js b/src/angular-vs-repeat.js
index d8e0f0c..e4bfda1 100644
--- a/src/angular-vs-repeat.js
+++ b/src/angular-vs-repeat.js
@@ -377,7 +377,7 @@
reinitialize();
autosizingRequired = false;
if ($scope.$root && !$scope.$root.$$phase) {
- $scope.$apply();
+ $scope.$digest();
}
}
} else {
@@ -424,7 +424,7 @@
autosizingRequired = true;
getFromMeasured();
if ($scope.$root && !$scope.$root.$$phase) {
- $scope.$apply();
+ $scope.$digest();
}
}
@@ -451,28 +451,34 @@
_minStartIndex,
_maxEndIndex;
- $scope.$on('vsRenderAll', function() {//e , quantum) {
- if (options.latch) {
- setTimeout(() => {
- // var __endIndex = Math.min($scope.vsRepeat.endIndex + (quantum || 1), originalLength);
- const __endIndex = originalLength;
- _maxEndIndex = Math.max(__endIndex, _maxEndIndex);
+ $scope.$on('vsRenderAll', function() {
+ if (!options.latch) {
+ return;
+ }
- $scope.vsRepeat.endIndex = options.latch ? _maxEndIndex : __endIndex;
- $scope[collectionName] = originalCollection.slice($scope.vsRepeat.startIndex, $scope.vsRepeat.endIndex);
+ if ($scope.vsRepeat.endIndex === originalLength) {
+ $scope.$emit('vsRenderAllDone');
+ return;
+ }
- _prevEndIndex = $scope.vsRepeat.endIndex;
+ setTimeout(() => {
+ // var __endIndex = Math.min($scope.vsRepeat.endIndex + (quantum || 1), originalLength);
+ const __endIndex = originalLength;
+ _maxEndIndex = Math.max(__endIndex, _maxEndIndex);
- $scope.$$postDigest(() => {
- $beforeContent.css(getLayoutProp(), 0);
- $afterContent.css(getLayoutProp(), 0);
- });
+ $scope.vsRepeat.endIndex = options.latch ? _maxEndIndex : __endIndex;
+ $scope[collectionName] = originalCollection.slice($scope.vsRepeat.startIndex, $scope.vsRepeat.endIndex);
- $scope.$apply(() => {
- $scope.$emit('vsRenderAllDone');
- });
- });
- }
+ _prevEndIndex = $scope.vsRepeat.endIndex;
+
+ $beforeContent.css(getLayoutProp(), 0);
+ $afterContent.css(getLayoutProp(), 0);
+
+ $scope.$emit('vsRenderAllDone');
+ if ($scope.$root && !$scope.$root.$$phase) {
+ $scope.$digest();
+ }
+ });
});
function reinitialize() {
@@ -496,7 +502,7 @@
if (ch !== _prevClientSize) {
reinitialize();
if ($scope.$root && !$scope.$root.$$phase) {
- $scope.$apply();
+ $scope.$digest();
}
}
_prevClientSize = ch;
diff --git a/test/spec.js b/test/spec.js
index 63b36bf..3a08bd7 100644
--- a/test/spec.js
+++ b/test/spec.js
@@ -185,7 +185,7 @@
it('should support manually provided unique element size', function(done){
$element = $compile([
'',
- '
',
+ '
',
' {{foo.value}}',
'
',
'
',
@@ -196,8 +196,7 @@
setTimeout(() => {
var elems = getElements($element);
- expect(elems.length).to.be.greaterThan(1);
- expect(elems.length).to.be.lessThan(5);
+ expect(elems.length).to.equal(2);
done();
});
});
@@ -535,7 +534,7 @@
done();
});
- it.only('should properly calculate start and end index with element beyond', function (done) {
+ it('should properly calculate start and end index with element beyond', function (done) {
$element = angular.element(`