Skip to content

Commit f906318

Browse files
chore(all): prepare release 1.0.0-beta.3.3.0
1 parent 932d92d commit f906318

32 files changed

+781
-393
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": "1.0.0-beta.3.2.0",
3+
"version": "1.0.0-beta.3.3.0",
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: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ define(['exports', 'aurelia-templating-resources', './utilities'], function (exp
8484
repeat.updateBindings(view);
8585
}
8686

87-
var minLength = Math.min(repeat._viewsLength, items.length);
87+
var minLength = Math.min(repeat._viewsLength, itemsLength);
8888
for (var _i = viewsLength; _i < minLength; _i++) {
8989
var overrideContext = (0, _aureliaTemplatingResources.createFullOverrideContext)(repeat, items[_i], _i, itemsLength);
9090
repeat.addView(overrideContext.bindingContext, overrideContext);
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
define(['exports', 'aurelia-templating-resources'], function (exports, _aureliaTemplatingResources) {
2+
'use strict';
3+
4+
Object.defineProperty(exports, "__esModule", {
5+
value: true
6+
});
7+
exports.NullVirtualRepeatStrategy = undefined;
8+
9+
10+
11+
function _possibleConstructorReturn(self, call) {
12+
if (!self) {
13+
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
14+
}
15+
16+
return call && (typeof call === "object" || typeof call === "function") ? call : self;
17+
}
18+
19+
function _inherits(subClass, superClass) {
20+
if (typeof superClass !== "function" && superClass !== null) {
21+
throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
22+
}
23+
24+
subClass.prototype = Object.create(superClass && superClass.prototype, {
25+
constructor: {
26+
value: subClass,
27+
enumerable: false,
28+
writable: true,
29+
configurable: true
30+
}
31+
});
32+
if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;
33+
}
34+
35+
var NullVirtualRepeatStrategy = exports.NullVirtualRepeatStrategy = function (_NullRepeatStrategy) {
36+
_inherits(NullVirtualRepeatStrategy, _NullRepeatStrategy);
37+
38+
function NullVirtualRepeatStrategy() {
39+
40+
41+
return _possibleConstructorReturn(this, _NullRepeatStrategy.apply(this, arguments));
42+
}
43+
44+
NullVirtualRepeatStrategy.prototype.instanceChanged = function instanceChanged(repeat) {
45+
_NullRepeatStrategy.prototype.instanceChanged.call(this, repeat);
46+
repeat._resetCalculation();
47+
};
48+
49+
return NullVirtualRepeatStrategy;
50+
}(_aureliaTemplatingResources.NullRepeatStrategy);
51+
});

dist/amd/template-strategy.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ define(['exports', 'aurelia-dependency-injection', 'aurelia-pal', 'aurelia-templ
6464
};
6565

6666
TableStrategy.prototype.createTopBufferElement = function createTopBufferElement(element) {
67-
var elementName = element.parentNode.localName === 'ul' ? 'li' : 'div';
67+
var elementName = /^[uo]l$/.test(element.parentNode.localName) ? 'li' : 'div';
6868
var buffer = _aureliaPal.DOM.createElement(elementName);
6969
var tableElement = element.parentNode.parentNode;
7070
tableElement.parentNode.insertBefore(buffer, tableElement);
@@ -73,7 +73,7 @@ define(['exports', 'aurelia-dependency-injection', 'aurelia-pal', 'aurelia-templ
7373
};
7474

7575
TableStrategy.prototype.createBottomBufferElement = function createBottomBufferElement(element) {
76-
var elementName = element.parentNode.localName === 'ul' ? 'li' : 'div';
76+
var elementName = /^[uo]l$/.test(element.parentNode.localName) ? 'li' : 'div';
7777
var buffer = _aureliaPal.DOM.createElement(elementName);
7878
var tableElement = element.parentNode.parentNode;
7979
tableElement.parentNode.insertBefore(buffer, tableElement.nextSibling);
@@ -137,14 +137,14 @@ define(['exports', 'aurelia-dependency-injection', 'aurelia-pal', 'aurelia-templ
137137
};
138138

139139
DefaultTemplateStrategy.prototype.createTopBufferElement = function createTopBufferElement(element) {
140-
var elementName = element.parentNode.localName === 'ul' ? 'li' : 'div';
140+
var elementName = /^[uo]l$/.test(element.parentNode.localName) ? 'li' : 'div';
141141
var buffer = _aureliaPal.DOM.createElement(elementName);
142142
element.parentNode.insertBefore(buffer, element);
143143
return buffer;
144144
};
145145

146146
DefaultTemplateStrategy.prototype.createBottomBufferElement = function createBottomBufferElement(element) {
147-
var elementName = element.parentNode.localName === 'ul' ? 'li' : 'div';
147+
var elementName = /^[uo]l$/.test(element.parentNode.localName) ? 'li' : 'div';
148148
var buffer = _aureliaPal.DOM.createElement(elementName);
149149
element.parentNode.insertBefore(buffer, element.nextSibling);
150150
return buffer;

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

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

44
Object.defineProperty(exports, "__esModule", {
@@ -43,6 +43,9 @@ define(['exports', 'aurelia-templating-resources', './array-virtual-repeat-strat
4343
_this.matchers = [];
4444
_this.strategies = [];
4545

46+
_this.addStrategy(function (items) {
47+
return items === null || items === undefined;
48+
}, new _nullVirtualRepeatStrategy.NullVirtualRepeatStrategy());
4649
_this.addStrategy(function (items) {
4750
return items instanceof Array;
4851
}, new _arrayVirtualRepeatStrategy.ArrayVirtualRepeatStrategy());

dist/amd/virtual-repeat.js

Lines changed: 58 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -172,20 +172,9 @@ define(['exports', 'aurelia-dependency-injection', 'aurelia-binding', 'aurelia-t
172172

173173
VirtualRepeat.prototype.detached = function detached() {
174174
this.scrollContainer.removeEventListener('scroll', this.scrollListener);
175-
this._first = 0;
176-
this._previousFirst = 0;
177-
this._viewsLength = 0;
178-
this._lastRebind = 0;
179-
this._topBufferHeight = 0;
180-
this._bottomBufferHeight = 0;
181-
this._scrollingDown = false;
182-
this._scrollingUp = false;
183-
this._switchedDirection = false;
175+
this._resetCalculation();
184176
this._isAttached = false;
185-
this._ticking = false;
186-
this._hasCalculatedSizes = false;
187177
this.templateStrategy.removeBufferElements(this.element, this.topBuffer, this.bottomBuffer);
188-
this.isLastIndex = false;
189178
this.scrollContainer = null;
190179
this.scrollContainerHeight = null;
191180
this.distanceToTop = null;
@@ -210,40 +199,47 @@ define(['exports', 'aurelia-dependency-injection', 'aurelia-binding', 'aurelia-t
210199
var previousLastViewIndex = this._getIndexOfLastView();
211200

212201
var items = this.items;
202+
var shouldCalculateSize = !!items;
213203
this.strategy = this.strategyLocator.getStrategy(items);
214-
if (items.length > 0 && this.viewCount() === 0) {
215-
this.strategy.createFirstItem(this);
216-
}
217204

218-
if (this._itemsLength >= items.length) {
219-
this._skipNextScrollHandle = true;
220-
reducingItems = true;
205+
if (shouldCalculateSize) {
206+
if (items.length > 0 && this.viewCount() === 0) {
207+
this.strategy.createFirstItem(this);
208+
}
209+
210+
if (this._itemsLength >= items.length) {
211+
this._skipNextScrollHandle = true;
212+
reducingItems = true;
213+
}
214+
this._checkFixedHeightContainer();
215+
this._calcInitialHeights(items.length);
221216
}
222-
this._checkFixedHeightContainer();
223-
this._calcInitialHeights(items.length);
224217
if (!this.isOneTime && !this._observeInnerCollection()) {
225218
this._observeCollection();
226219
}
227220
this.strategy.instanceChanged(this, items, this._first);
228-
this._lastRebind = this._first;
229221

230-
if (reducingItems && previousLastViewIndex > this.items.length - 1) {
231-
if (this.scrollContainer.tagName === 'TBODY') {
232-
var realScrollContainer = this.scrollContainer.parentNode.parentNode;
233-
realScrollContainer.scrollTop = realScrollContainer.scrollTop + this.viewCount() * this.itemHeight;
234-
} else {
235-
this.scrollContainer.scrollTop = this.scrollContainer.scrollTop + this.viewCount() * this.itemHeight;
222+
if (shouldCalculateSize) {
223+
this._lastRebind = this._first;
224+
225+
if (reducingItems && previousLastViewIndex > this.items.length - 1) {
226+
if (this.scrollContainer.tagName === 'TBODY') {
227+
var realScrollContainer = this.scrollContainer.parentNode.parentNode;
228+
realScrollContainer.scrollTop = realScrollContainer.scrollTop + this.viewCount() * this.itemHeight;
229+
} else {
230+
this.scrollContainer.scrollTop = this.scrollContainer.scrollTop + this.viewCount() * this.itemHeight;
231+
}
236232
}
237-
}
238-
if (!reducingItems) {
239-
this._previousFirst = this._first;
240-
this._scrollingDown = true;
241-
this._scrollingUp = false;
233+
if (!reducingItems) {
234+
this._previousFirst = this._first;
235+
this._scrollingDown = true;
236+
this._scrollingUp = false;
242237

243-
this.isLastIndex = this._getIndexOfLastView() >= this.items.length - 1;
244-
}
238+
this.isLastIndex = this._getIndexOfLastView() >= this.items.length - 1;
239+
}
245240

246-
this._handleScroll();
241+
this._handleScroll();
242+
}
247243
};
248244

249245
VirtualRepeat.prototype.unbind = function unbind() {
@@ -277,6 +273,24 @@ define(['exports', 'aurelia-dependency-injection', 'aurelia-binding', 'aurelia-t
277273
}
278274
};
279275

276+
VirtualRepeat.prototype._resetCalculation = function _resetCalculation() {
277+
this._first = 0;
278+
this._previousFirst = 0;
279+
this._viewsLength = 0;
280+
this._lastRebind = 0;
281+
this._topBufferHeight = 0;
282+
this._bottomBufferHeight = 0;
283+
this._scrollingDown = false;
284+
this._scrollingUp = false;
285+
this._switchedDirection = false;
286+
this._ticking = false;
287+
this._hasCalculatedSizes = false;
288+
this._isAtTop = true;
289+
this.isLastIndex = false;
290+
this.elementsInView = 0;
291+
this._adjustBufferHeights();
292+
};
293+
280294
VirtualRepeat.prototype._onScroll = function _onScroll() {
281295
var _this4 = this;
282296

@@ -300,6 +314,9 @@ define(['exports', 'aurelia-dependency-injection', 'aurelia-binding', 'aurelia-t
300314
this._skipNextScrollHandle = false;
301315
return;
302316
}
317+
if (!this.items) {
318+
return;
319+
}
303320
var itemHeight = this.itemHeight;
304321
var scrollTop = this._fixedHeightContainer ? this.scrollContainer.scrollTop : pageYOffset - this.distanceToTop;
305322
this._first = Math.floor(scrollTop / itemHeight);
@@ -510,7 +527,12 @@ define(['exports', 'aurelia-dependency-injection', 'aurelia-binding', 'aurelia-t
510527
VirtualRepeat.prototype._calcInitialHeights = function _calcInitialHeights(itemsLength) {
511528
var _this7 = this;
512529

513-
if (this._viewsLength > 0 && this._itemsLength === itemsLength || this._viewsLength > 0 && itemsLength < 0) {
530+
var isSameLength = this._viewsLength > 0 && this._itemsLength === itemsLength;
531+
if (isSameLength) {
532+
return;
533+
}
534+
if (itemsLength < 1) {
535+
this._resetCalculation();
514536
return;
515537
}
516538
this._hasCalculatedSizes = true;

dist/aurelia-ui-virtualization.d.ts

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,5 @@
11
import {
2-
customAttribute,
3-
View,
4-
BoundViewFactory,
5-
ViewSlot,
6-
ViewResources,
7-
TargetInstruction,
8-
bindable,
9-
templateController
10-
} from 'aurelia-templating';
11-
import {
2+
NullRepeatStrategy,
123
updateOverrideContext,
134
ArrayRepeatStrategy,
145
createFullOverrideContext,
@@ -20,6 +11,16 @@ import {
2011
updateOneTimeBinding,
2112
viewsRequireLifecycle
2213
} from 'aurelia-templating-resources';
14+
import {
15+
customAttribute,
16+
View,
17+
BoundViewFactory,
18+
ViewSlot,
19+
ViewResources,
20+
TargetInstruction,
21+
bindable,
22+
templateController
23+
} from 'aurelia-templating';
2324
import {
2425
inject,
2526
Container
@@ -41,6 +42,9 @@ export declare interface TemplateStrategy {
4142
getLastView(bottomBuffer: Element): Element;
4243
getTopBufferDistance(topBuffer: Element): number;
4344
}
45+
export declare class NullVirtualRepeatStrategy extends NullRepeatStrategy {
46+
instanceChanged(repeat?: any): any;
47+
}
4448
export declare class DomHelper {
4549
getElementDistanceToTopOfDocument(element: Element): number;
4650
hasOverflowScroll(element: Element): boolean;

0 commit comments

Comments
 (0)