Skip to content

Commit f311d24

Browse files
chore(all): prepare release 0.4.5
1 parent 1eda5e2 commit f311d24

26 files changed

+305
-227
lines changed

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "aurelia-ui-virtualization",
3-
"version": "0.4.4",
3+
"version": "0.4.5",
44
"description": "A plugin that provides a virtualized repeater and other virtualization services.",
55
"keywords": [
66
"aurelia",

dist/amd/array-virtual-repeat-strategy.js

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
define(['exports', 'aurelia-templating-resources/array-repeat-strategy', 'aurelia-templating-resources/repeat-utilities', './utilities'], function (exports, _arrayRepeatStrategy, _repeatUtilities, _utilities) {
1+
define(['exports', 'aurelia-templating-resources', './utilities'], function (exports, _aureliaTemplatingResources, _utilities) {
22
'use strict';
33

44
Object.defineProperty(exports, "__esModule", {
@@ -46,7 +46,7 @@ define(['exports', 'aurelia-templating-resources/array-repeat-strategy', 'aureli
4646
}
4747

4848
ArrayVirtualRepeatStrategy.prototype.createFirstItem = function createFirstItem(repeat) {
49-
var overrideContext = (0, _repeatUtilities.createFullOverrideContext)(repeat, repeat.items[0], 0, 1);
49+
var overrideContext = (0, _aureliaTemplatingResources.createFullOverrideContext)(repeat, repeat.items[0], 0, 1);
5050
repeat.addView(overrideContext.bindingContext, overrideContext);
5151
};
5252

@@ -56,7 +56,7 @@ define(['exports', 'aurelia-templating-resources/array-repeat-strategy', 'aureli
5656

5757
ArrayVirtualRepeatStrategy.prototype._standardProcessInstanceChanged = function _standardProcessInstanceChanged(repeat, items) {
5858
for (var i = 1, ii = repeat._viewsLength; i < ii; ++i) {
59-
var overrideContext = (0, _repeatUtilities.createFullOverrideContext)(repeat, items[i], i, ii);
59+
var overrideContext = (0, _aureliaTemplatingResources.createFullOverrideContext)(repeat, items[i], i, ii);
6060
repeat.addView(overrideContext.bindingContext, overrideContext);
6161
}
6262
};
@@ -90,7 +90,7 @@ define(['exports', 'aurelia-templating-resources/array-repeat-strategy', 'aureli
9090

9191
var minLength = Math.min(repeat._viewsLength, items.length);
9292
for (var _i = viewsLength; _i < minLength; _i++) {
93-
var overrideContext = (0, _repeatUtilities.createFullOverrideContext)(repeat, items[_i], _i, itemsLength);
93+
var overrideContext = (0, _aureliaTemplatingResources.createFullOverrideContext)(repeat, items[_i], _i, itemsLength);
9494
repeat.addView(overrideContext.bindingContext, overrideContext);
9595
}
9696
};
@@ -145,8 +145,9 @@ define(['exports', 'aurelia-templating-resources/array-repeat-strategy', 'aureli
145145
for (var i = 0, ii = splices.length; i < ii; ++i) {
146146
var splice = splices[i];
147147
var removed = splice.removed;
148-
for (var j = 0, jj = removed.length; j < jj; ++j) {
149-
var viewOrPromise = this._removeViewAt(repeat, splice.index + removeDelta + rmPromises.length, true);
148+
var removedLength = removed.length;
149+
for (var j = 0, jj = removedLength; j < jj; ++j) {
150+
var viewOrPromise = this._removeViewAt(repeat, splice.index + removeDelta + rmPromises.length, true, j, removedLength);
150151
if (viewOrPromise instanceof Promise) {
151152
rmPromises.push(viewOrPromise);
152153
}
@@ -164,12 +165,18 @@ define(['exports', 'aurelia-templating-resources/array-repeat-strategy', 'aureli
164165
(0, _utilities.updateVirtualOverrideContexts)(repeat, 0);
165166
};
166167

167-
ArrayVirtualRepeatStrategy.prototype._removeViewAt = function _removeViewAt(repeat, collectionIndex, returnToCache) {
168+
ArrayVirtualRepeatStrategy.prototype._removeViewAt = function _removeViewAt(repeat, collectionIndex, returnToCache, j, removedLength) {
168169
var viewOrPromise = void 0;
169170
var view = void 0;
170171
var viewSlot = repeat.viewSlot;
171172
var viewCount = repeat.viewCount();
172173
var viewAddIndex = void 0;
174+
var removeMoreThanInDom = removedLength > viewCount;
175+
if (repeat._viewsLength <= j) {
176+
repeat._bottomBufferHeight = repeat._bottomBufferHeight - repeat.itemHeight;
177+
repeat._adjustBufferHeights();
178+
return;
179+
}
173180

174181
if (!this._isIndexBeforeViewSlot(repeat, viewSlot, collectionIndex) && !this._isIndexAfterViewSlot(repeat, viewSlot, collectionIndex)) {
175182
var viewIndex = this._getViewIndex(repeat, viewSlot, collectionIndex);
@@ -178,7 +185,12 @@ define(['exports', 'aurelia-templating-resources/array-repeat-strategy', 'aureli
178185
var collectionAddIndex = void 0;
179186
if (repeat._bottomBufferHeight > repeat.itemHeight) {
180187
viewAddIndex = viewCount;
181-
collectionAddIndex = repeat._getIndexOfLastView() + 1;
188+
if (!removeMoreThanInDom) {
189+
var lastViewItem = repeat._getLastViewItem();
190+
collectionAddIndex = repeat.items.indexOf(lastViewItem) + 1;
191+
} else {
192+
collectionAddIndex = j;
193+
}
182194
repeat._bottomBufferHeight = repeat._bottomBufferHeight - repeat.itemHeight;
183195
} else if (repeat._topBufferHeight > 0) {
184196
viewAddIndex = 0;
@@ -187,12 +199,10 @@ define(['exports', 'aurelia-templating-resources/array-repeat-strategy', 'aureli
187199
}
188200
var data = repeat.items[collectionAddIndex];
189201
if (data) {
190-
var overrideContext = (0, _repeatUtilities.createFullOverrideContext)(repeat, repeat.items[collectionAddIndex], collectionAddIndex, repeat.items.length);
202+
var overrideContext = (0, _aureliaTemplatingResources.createFullOverrideContext)(repeat, data, collectionAddIndex, repeat.items.length);
191203
view = repeat.viewFactory.create();
192204
view.bind(overrideContext.bindingContext, overrideContext);
193205
}
194-
} else {
195-
return viewOrPromise;
196206
}
197207
} else if (this._isIndexBeforeViewSlot(repeat, viewSlot, collectionIndex)) {
198208
if (repeat._bottomBufferHeight > 0) {
@@ -210,11 +220,9 @@ define(['exports', 'aurelia-templating-resources/array-repeat-strategy', 'aureli
210220
repeat.viewSlot.insert(viewAddIndex, view);
211221
repeat._adjustBufferHeights();
212222
});
213-
return undefined;
214223
} else if (view) {
215224
repeat.viewSlot.insert(viewAddIndex, view);
216225
}
217-
218226
repeat._adjustBufferHeights();
219227
};
220228

@@ -247,7 +255,7 @@ define(['exports', 'aurelia-templating-resources/array-repeat-strategy', 'aureli
247255
for (; addIndex < end; ++addIndex) {
248256
var hasDistanceToBottomViewPort = (0, _utilities.getElementDistanceToBottomViewPort)(repeat.viewStrategy.getLastElement(repeat.bottomBuffer)) > 0;
249257
if (repeat.viewCount() === 0 || !this._isIndexBeforeViewSlot(repeat, viewSlot, addIndex) && !this._isIndexAfterViewSlot(repeat, viewSlot, addIndex) || hasDistanceToBottomViewPort) {
250-
var overrideContext = (0, _repeatUtilities.createFullOverrideContext)(repeat, array[addIndex], addIndex, arrayLength);
258+
var overrideContext = (0, _aureliaTemplatingResources.createFullOverrideContext)(repeat, array[addIndex], addIndex, arrayLength);
251259
repeat.insertView(addIndex, overrideContext.bindingContext, overrideContext);
252260
if (!repeat._hasCalculatedSizes) {
253261
repeat._calcInitialHeights(1);
@@ -273,5 +281,5 @@ define(['exports', 'aurelia-templating-resources/array-repeat-strategy', 'aureli
273281
};
274282

275283
return ArrayVirtualRepeatStrategy;
276-
}(_arrayRepeatStrategy.ArrayRepeatStrategy);
284+
}(_aureliaTemplatingResources.ArrayRepeatStrategy);
277285
});

dist/amd/aurelia-ui-virtualization.d.ts

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,19 @@
11
declare module 'aurelia-ui-virtualization' {
22
import {
33
updateOverrideContext,
4+
ArrayRepeatStrategy,
45
createFullOverrideContext,
6+
RepeatStrategyLocator,
7+
AbstractRepeater,
58
getItemsSourceExpression,
69
isOneTime,
710
unwrapExpression,
8-
updateOneTimeBinding
9-
} from 'aurelia-templating-resources/repeat-utilities';
10-
import {
11-
ArrayRepeatStrategy
12-
} from 'aurelia-templating-resources/array-repeat-strategy';
11+
updateOneTimeBinding,
12+
viewsRequireLifecycle
13+
} from 'aurelia-templating-resources';
1314
import {
1415
DOM
1516
} from 'aurelia-pal';
16-
import {
17-
RepeatStrategyLocator
18-
} from 'aurelia-templating-resources/repeat-strategy-locator';
1917
import {
2018
inject
2119
} from 'aurelia-dependency-injection';
@@ -31,12 +29,6 @@ declare module 'aurelia-ui-virtualization' {
3129
bindable,
3230
templateController
3331
} from 'aurelia-templating';
34-
import {
35-
AbstractRepeater
36-
} from 'aurelia-templating-resources';
37-
import {
38-
viewsRequireLifecycle
39-
} from 'aurelia-templating-resources/analyze-view-factory';
4032
export interface ViewStrategy {
4133
getScrollContainer(element: Element): Element;
4234
moveViewFirst(view: View, topBuffer: Element): void;

dist/amd/utilities.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
define(['exports', 'aurelia-templating-resources/repeat-utilities'], function (exports, _repeatUtilities) {
1+
define(['exports', 'aurelia-templating-resources'], function (exports, _aureliaTemplatingResources) {
22
'use strict';
33

44
Object.defineProperty(exports, "__esModule", {
@@ -48,14 +48,14 @@ define(['exports', 'aurelia-templating-resources/repeat-utilities'], function (e
4848
var delta = repeat._topBufferHeight / repeat.itemHeight;
4949

5050
for (; startIndex < viewLength; ++startIndex) {
51-
(0, _repeatUtilities.updateOverrideContext)(views[startIndex].overrideContext, startIndex + delta, collectionLength);
51+
(0, _aureliaTemplatingResources.updateOverrideContext)(views[startIndex].overrideContext, startIndex + delta, collectionLength);
5252
}
5353
}
5454

5555
function rebindAndMoveView(repeat, view, index, moveToBottom) {
5656
var items = repeat.items;
5757
var viewSlot = repeat.viewSlot;
58-
(0, _repeatUtilities.updateOverrideContext)(view.overrideContext, index, items.length);
58+
(0, _aureliaTemplatingResources.updateOverrideContext)(view.overrideContext, index, items.length);
5959
view.bindingContext[repeat.local] = items[index];
6060
if (moveToBottom) {
6161
viewSlot.children.push(viewSlot.children.shift());

dist/amd/virtual-repeat-strategy-locator.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
define(['exports', 'aurelia-templating-resources/repeat-strategy-locator', './array-virtual-repeat-strategy'], function (exports, _repeatStrategyLocator, _arrayVirtualRepeatStrategy) {
1+
define(['exports', 'aurelia-templating-resources', './array-virtual-repeat-strategy'], function (exports, _aureliaTemplatingResources, _arrayVirtualRepeatStrategy) {
22
'use strict';
33

44
Object.defineProperty(exports, "__esModule", {
@@ -54,5 +54,5 @@ define(['exports', 'aurelia-templating-resources/repeat-strategy-locator', './ar
5454
}
5555

5656
return VirtualRepeatStrategyLocator;
57-
}(_repeatStrategyLocator.RepeatStrategyLocator);
57+
}(_aureliaTemplatingResources.RepeatStrategyLocator);
5858
});

dist/amd/virtual-repeat.js

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
define(['exports', 'aurelia-dependency-injection', 'aurelia-binding', 'aurelia-templating', 'aurelia-templating-resources', 'aurelia-templating-resources/repeat-utilities', 'aurelia-templating-resources/analyze-view-factory', 'aurelia-pal', './utilities', './dom-helper', './virtual-repeat-strategy-locator', './view-strategy'], function (exports, _aureliaDependencyInjection, _aureliaBinding, _aureliaTemplating, _aureliaTemplatingResources, _repeatUtilities, _analyzeViewFactory, _aureliaPal, _utilities, _domHelper, _virtualRepeatStrategyLocator, _viewStrategy) {
1+
define(['exports', 'aurelia-dependency-injection', 'aurelia-binding', 'aurelia-templating', 'aurelia-templating-resources', 'aurelia-pal', './utilities', './dom-helper', './virtual-repeat-strategy-locator', './view-strategy'], function (exports, _aureliaDependencyInjection, _aureliaBinding, _aureliaTemplating, _aureliaTemplatingResources, _aureliaPal, _utilities, _domHelper, _virtualRepeatStrategyLocator, _viewStrategy) {
22
'use strict';
33

44
Object.defineProperty(exports, "__esModule", {
@@ -89,7 +89,7 @@ define(['exports', 'aurelia-dependency-injection', 'aurelia-binding', 'aurelia-t
8989

9090
var _this = _possibleConstructorReturn(this, _AbstractRepeater.call(this, {
9191
local: 'item',
92-
viewsRequireLifecycle: (0, _analyzeViewFactory.viewsRequireLifecycle)(viewFactory)
92+
viewsRequireLifecycle: (0, _aureliaTemplatingResources.viewsRequireLifecycle)(viewFactory)
9393
}));
9494

9595
_this._first = 0;
@@ -120,8 +120,8 @@ define(['exports', 'aurelia-dependency-injection', 'aurelia-binding', 'aurelia-t
120120
_this.observerLocator = observerLocator;
121121
_this.strategyLocator = strategyLocator;
122122
_this.viewStrategyLocator = viewStrategyLocator;
123-
_this.sourceExpression = (0, _repeatUtilities.getItemsSourceExpression)(_this.instruction, 'virtual-repeat.for');
124-
_this.isOneTime = (0, _repeatUtilities.isOneTime)(_this.sourceExpression);
123+
_this.sourceExpression = (0, _aureliaTemplatingResources.getItemsSourceExpression)(_this.instruction, 'virtual-repeat.for');
124+
_this.isOneTime = (0, _aureliaTemplatingResources.isOneTime)(_this.sourceExpression);
125125
_this.domHelper = domHelper;
126126
return _this;
127127
}
@@ -382,7 +382,21 @@ define(['exports', 'aurelia-dependency-injection', 'aurelia-binding', 'aurelia-t
382382
};
383383

384384
VirtualRepeat.prototype._getIndexOfLastView = function _getIndexOfLastView() {
385-
return this.view(this.viewCount() - 1).overrideContext.$index;
385+
var view = this.view(this.viewCount() - 1);
386+
if (view) {
387+
return view.overrideContext.$index;
388+
}
389+
390+
return -1;
391+
};
392+
393+
VirtualRepeat.prototype._getLastViewItem = function _getLastViewItem() {
394+
var children = this.viewSlot.children;
395+
if (!children.length) {
396+
return undefined;
397+
}
398+
var lastViewItem = children[children.length - 1].bindingContext[this.local];
399+
return lastViewItem;
386400
};
387401

388402
VirtualRepeat.prototype._getIndexOfFirstView = function _getIndexOfFirstView() {
@@ -439,7 +453,7 @@ define(['exports', 'aurelia-dependency-injection', 'aurelia-binding', 'aurelia-t
439453
};
440454

441455
VirtualRepeat.prototype._getInnerCollection = function _getInnerCollection() {
442-
var expression = (0, _repeatUtilities.unwrapExpression)(this.sourceExpression);
456+
var expression = (0, _aureliaTemplatingResources.unwrapExpression)(this.sourceExpression);
443457
if (!expression) {
444458
return null;
445459
}
@@ -490,14 +504,14 @@ define(['exports', 'aurelia-dependency-injection', 'aurelia-binding', 'aurelia-t
490504
VirtualRepeat.prototype.updateBindings = function updateBindings(view) {
491505
var j = view.bindings.length;
492506
while (j--) {
493-
(0, _repeatUtilities.updateOneTimeBinding)(view.bindings[j]);
507+
(0, _aureliaTemplatingResources.updateOneTimeBinding)(view.bindings[j]);
494508
}
495509
j = view.controllers.length;
496510
while (j--) {
497511
var k = view.controllers[j].boundProperties.length;
498512
while (k--) {
499513
var binding = view.controllers[j].boundProperties[k].binding;
500-
(0, _repeatUtilities.updateOneTimeBinding)(binding);
514+
(0, _aureliaTemplatingResources.updateOneTimeBinding)(binding);
501515
}
502516
}
503517
};

dist/aurelia-ui-virtualization.d.ts

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,19 @@
11
declare module 'aurelia-ui-virtualization' {
22
import {
33
updateOverrideContext,
4+
ArrayRepeatStrategy,
45
createFullOverrideContext,
6+
RepeatStrategyLocator,
7+
AbstractRepeater,
58
getItemsSourceExpression,
69
isOneTime,
710
unwrapExpression,
8-
updateOneTimeBinding
9-
} from 'aurelia-templating-resources/repeat-utilities';
10-
import {
11-
ArrayRepeatStrategy
12-
} from 'aurelia-templating-resources/array-repeat-strategy';
11+
updateOneTimeBinding,
12+
viewsRequireLifecycle
13+
} from 'aurelia-templating-resources';
1314
import {
1415
DOM
1516
} from 'aurelia-pal';
16-
import {
17-
RepeatStrategyLocator
18-
} from 'aurelia-templating-resources/repeat-strategy-locator';
1917
import {
2018
inject
2119
} from 'aurelia-dependency-injection';
@@ -31,12 +29,6 @@ declare module 'aurelia-ui-virtualization' {
3129
bindable,
3230
templateController
3331
} from 'aurelia-templating';
34-
import {
35-
AbstractRepeater
36-
} from 'aurelia-templating-resources';
37-
import {
38-
viewsRequireLifecycle
39-
} from 'aurelia-templating-resources/analyze-view-factory';
4032
export interface ViewStrategy {
4133
getScrollContainer(element: Element): Element;
4234
moveViewFirst(view: View, topBuffer: Element): void;

0 commit comments

Comments
 (0)