Skip to content

Commit 0e87883

Browse files
committed
Min/max indexes have to be adjusted each time the buffer.append/prepend is called
1 parent c3d30bb commit 0e87883

File tree

3 files changed

+26
-40
lines changed

3 files changed

+26
-40
lines changed

dist/ui-scroll.js

Lines changed: 21 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
/*!
2-
* angular-ui-scroll
3-
* https://github.com/angular-ui/ui-scroll.git
4-
* Version: 1.5.0 -- 2016-06-09T21:24:24.010Z
5-
* License: MIT
6-
*/
7-
8-
9-
(function () {
1+
/*!
2+
* angular-ui-scroll
3+
* https://github.com/angular-ui/ui-scroll.git
4+
* Version: 1.5.0 -- 2016-06-15T12:17:35.738Z
5+
* License: MIT
6+
*/
7+
8+
9+
(function () {
1010
'use strict';
1111

1212
var _typeof = typeof Symbol === 'function' && typeof Symbol.iterator === 'symbol' ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === 'function' && obj.constructor === Symbol ? 'symbol' : typeof obj; };
@@ -136,12 +136,14 @@ angular.module('ui.scroll', []).directive('uiScrollViewport', function () {
136136
++buffer.next;
137137
buffer.insert('append', item);
138138
});
139+
buffer.maxIndex = buffer.eof ? buffer.next - 1 : Math.max(buffer.next - 1, buffer.maxIndex);
139140
},
140141
prepend: function prepend(items) {
141142
items.reverse().forEach(function (item) {
142143
--buffer.first;
143144
buffer.insert('prepend', item);
144145
});
146+
buffer.minIndex = buffer.bof ? buffer.minIndex = buffer.first : Math.min(buffer.first, buffer.minIndex);
145147
},
146148

147149

@@ -189,12 +191,6 @@ angular.module('ui.scroll', []).directive('uiScrollViewport', function () {
189191

190192
return removeElementAnimated(arg1);
191193
},
192-
setUpper: function setUpper() {
193-
buffer.maxIndex = buffer.eof ? buffer.next - 1 : Math.max(buffer.next - 1, buffer.maxIndex);
194-
},
195-
setLower: function setLower() {
196-
buffer.minIndex = buffer.bof ? buffer.minIndex = buffer.first : Math.min(buffer.first, buffer.minIndex);
197-
},
198194
effectiveHeight: function effectiveHeight(elements) {
199195
if (!elements.length) return 0;
200196
var top = Number.MAX_VALUE;
@@ -216,8 +212,8 @@ angular.module('ui.scroll', []).directive('uiScrollViewport', function () {
216212
function Viewport(buffer, element, viewportController, attrs) {
217213
var PADDING_MIN = 0.3;
218214
var PADDING_DEFAULT = 0.5;
219-
var topPadding = void 0;
220-
var bottomPadding = void 0;
215+
var topPadding = undefined;
216+
var bottomPadding = undefined;
221217
var viewport = viewportController && viewportController.viewport ? viewportController.viewport : angular.element(window);
222218
var container = viewportController && viewportController.container ? viewportController.container : undefined;
223219

@@ -252,7 +248,7 @@ angular.module('ui.scroll', []).directive('uiScrollViewport', function () {
252248
}
253249

254250
function Padding(template) {
255-
var result = void 0;
251+
var result = undefined;
256252

257253
switch (template.tagName) {
258254
case 'dl':
@@ -482,11 +478,11 @@ angular.module('ui.scroll', []).directive('uiScrollViewport', function () {
482478
};
483479

484480
this.calculateProperties = function () {
485-
var item = void 0,
486-
itemHeight = void 0,
487-
itemTop = void 0,
488-
isNewRow = void 0,
489-
rowTop = void 0;
481+
var item = undefined,
482+
itemHeight = undefined,
483+
itemTop = undefined,
484+
isNewRow = undefined,
485+
rowTop = undefined;
490486
var topHeight = 0;
491487
for (var i = 0; i < buffer.length; i++) {
492488
item = buffer[i];
@@ -547,7 +543,7 @@ angular.module('ui.scroll', []).directive('uiScrollViewport', function () {
547543
return;
548544
}
549545

550-
var keepIt = void 0;
546+
var keepIt = undefined;
551547
var pos = buffer.indexOf(wrapper) + 1;
552548

553549
newItems.reverse().forEach(function (newItem) {
@@ -729,7 +725,7 @@ angular.module('ui.scroll', []).directive('uiScrollViewport', function () {
729725
}
730726

731727
function createElement(wrapper, insertAfter, insertElement) {
732-
var promises = void 0;
728+
var promises = undefined;
733729
var sibling = insertAfter > 0 ? buffer[insertAfter - 1].element : undefined;
734730
linker(function (clone, scope) {
735731
promises = insertElement(clone, sibling);
@@ -895,7 +891,6 @@ angular.module('ui.scroll', []).directive('uiScrollViewport', function () {
895891
if (result.length > 0) {
896892
viewport.clipTop();
897893
buffer.append(result);
898-
buffer.setUpper();
899894
}
900895

901896
adjustBufferAfterFetch(rid);
@@ -921,7 +916,6 @@ angular.module('ui.scroll', []).directive('uiScrollViewport', function () {
921916
viewport.clipBottom();
922917
}
923918
buffer.prepend(result);
924-
buffer.setLower();
925919
}
926920

927921
adjustBufferAfterFetch(rid);

0 commit comments

Comments
 (0)