Skip to content

Commit

Permalink
chore(all): prepare release 1.0.0-rc1
Browse files Browse the repository at this point in the history
  • Loading branch information
EisenbergEffect committed Jun 12, 2020
1 parent 7af55a8 commit 54df50c
Show file tree
Hide file tree
Showing 13 changed files with 481 additions and 193 deletions.
80 changes: 57 additions & 23 deletions dist/amd/aurelia-ui-virtualization.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ define(['exports', 'aurelia-binding', 'aurelia-templating', 'aurelia-templating-
}
current = current.parentNode;
}
return htmlElement;
return doc.scrollingElement || htmlElement;
};
var getElementDistanceToTopOfDocument = function (element) {
var box = element.getBoundingClientRect();
Expand Down Expand Up @@ -134,6 +134,9 @@ define(['exports', 'aurelia-binding', 'aurelia-templating', 'aurelia-templating-
var overrideContext = aureliaTemplatingResources.createFullOverrideContext(repeat, repeat.items[0], 0, 1);
return repeat.addView(overrideContext.bindingContext, overrideContext);
};
ArrayVirtualRepeatStrategy.prototype.count = function (items) {
return items.length;
};
ArrayVirtualRepeatStrategy.prototype.initCalculation = function (repeat, items) {
var itemCount = items.length;
if (!(itemCount > 0)) {
Expand Down Expand Up @@ -197,7 +200,7 @@ define(['exports', 'aurelia-binding', 'aurelia-templating', 'aurelia-templating-
return lastIndex === -1
? true
: itemCount > 0
? lastIndex > (itemCount - repeat.edgeDistance)
? lastIndex > (itemCount - 1 - repeat.edgeDistance)
: false;
};
ArrayVirtualRepeatStrategy.prototype.instanceChanged = function (repeat, items, first) {
Expand Down Expand Up @@ -473,6 +476,12 @@ define(['exports', 'aurelia-binding', 'aurelia-templating', 'aurelia-templating-
function NullVirtualRepeatStrategy() {
return _super !== null && _super.apply(this, arguments) || this;
}
NullVirtualRepeatStrategy.prototype.createFirstRow = function () {
return null;
};
NullVirtualRepeatStrategy.prototype.count = function (items) {
return 0;
};
NullVirtualRepeatStrategy.prototype.getViewRange = function (repeat, scrollerInfo) {
return [0, 0];
};
Expand All @@ -490,9 +499,6 @@ define(['exports', 'aurelia-binding', 'aurelia-templating', 'aurelia-templating-
= 0;
return 2;
};
NullVirtualRepeatStrategy.prototype.createFirstRow = function () {
return null;
};
NullVirtualRepeatStrategy.prototype.instanceMutated = function () { };
NullVirtualRepeatStrategy.prototype.instanceChanged = function (repeat) {
repeat.removeAllViews(true, false);
Expand Down Expand Up @@ -544,7 +550,7 @@ define(['exports', 'aurelia-binding', 'aurelia-templating', 'aurelia-templating-
var parent = element.parentNode;
return [
parent.insertBefore(aureliaPal.DOM.createElement('div'), element),
parent.insertBefore(aureliaPal.DOM.createElement('div'), element.nextSibling)
parent.insertBefore(aureliaPal.DOM.createElement('div'), element.nextSibling),
];
};
DefaultTemplateStrategy.prototype.removeBuffers = function (el, topBuffer, bottomBuffer) {
Expand Down Expand Up @@ -575,7 +581,7 @@ define(['exports', 'aurelia-binding', 'aurelia-templating', 'aurelia-templating-
var parent = element.parentNode;
return [
parent.insertBefore(aureliaPal.DOM.createElement('tr'), element),
parent.insertBefore(aureliaPal.DOM.createElement('tr'), element.nextSibling)
parent.insertBefore(aureliaPal.DOM.createElement('tr'), element.nextSibling),
];
};
return BaseTableTemplateStrategy;
Expand Down Expand Up @@ -610,7 +616,7 @@ define(['exports', 'aurelia-binding', 'aurelia-templating', 'aurelia-templating-
var parent = element.parentNode;
return [
parent.insertBefore(aureliaPal.DOM.createElement('li'), element),
parent.insertBefore(aureliaPal.DOM.createElement('li'), element.nextSibling)
parent.insertBefore(aureliaPal.DOM.createElement('li'), element.nextSibling),
];
};
return ListTemplateStrategy;
Expand Down Expand Up @@ -644,7 +650,7 @@ define(['exports', 'aurelia-binding', 'aurelia-templating', 'aurelia-templating-

var VirtualizationEvents = Object.assign(Object.create(null), {
scrollerSizeChange: 'virtual-repeat-scroller-size-changed',
itemSizeChange: 'virtual-repeat-item-size-changed'
itemSizeChange: 'virtual-repeat-item-size-changed',
});

var getResizeObserverClass = function () { return aureliaPal.PLATFORM.global.ResizeObserver; };
Expand All @@ -654,7 +660,7 @@ define(['exports', 'aurelia-binding', 'aurelia-templating', 'aurelia-templating-
function VirtualRepeat(element, viewFactory, instruction, viewSlot, viewResources, observerLocator, collectionStrategyLocator, templateStrategyLocator) {
var _this = _super.call(this, {
local: 'item',
viewsRequireLifecycle: aureliaTemplatingResources.viewsRequireLifecycle(viewFactory)
viewsRequireLifecycle: aureliaTemplatingResources.viewsRequireLifecycle(viewFactory),
}) || this;
_this.$first = 0;
_this._isAttached = false;
Expand Down Expand Up @@ -695,15 +701,15 @@ define(['exports', 'aurelia-binding', 'aurelia-templating', 'aurelia-templating-
aureliaTemplating.ViewResources,
aureliaBinding.ObserverLocator,
VirtualRepeatStrategyLocator,
TemplateStrategyLocator
TemplateStrategyLocator,
];
};
VirtualRepeat.$resource = function () {
return {
type: 'attribute',
name: 'virtual-repeat',
templateController: true,
bindables: ['items', 'local']
bindables: ['items', 'local'],
};
};
VirtualRepeat.prototype.bind = function (bindingContext, overrideContext) {
Expand Down Expand Up @@ -852,7 +858,7 @@ define(['exports', 'aurelia-binding', 'aurelia-templating', 'aurelia-templating-
scrollTop: scroller.scrollTop,
height: scroller === htmlElement
? innerHeight
: calcScrollHeight(scroller)
: calcScrollHeight(scroller),
};
};
VirtualRepeat.prototype.resetCalculation = function () {
Expand Down Expand Up @@ -883,7 +889,7 @@ define(['exports', 'aurelia-binding', 'aurelia-templating', 'aurelia-templating-
this._handlingMutations = false;
}
};
VirtualRepeat.prototype._handleScroll = function (currentScrollerInfo, prevScrollerInfo) {
VirtualRepeat.prototype._handleScroll = function (current_scroller_info, prev_scroller_info) {
if (!this._isAttached) {
return;
}
Expand All @@ -898,7 +904,7 @@ define(['exports', 'aurelia-binding', 'aurelia-templating', 'aurelia-templating-
var strategy = this.strategy;
var old_range_start_index = this.$first;
var old_range_end_index = this.lastViewIndex();
var _a = strategy.getViewRange(this, currentScrollerInfo), new_range_start_index = _a[0], new_range_end_index = _a[1];
var _a = strategy.getViewRange(this, current_scroller_info), new_range_start_index = _a[0], new_range_end_index = _a[1];
var scrolling_state = new_range_start_index > old_range_start_index
? 1
: new_range_start_index < old_range_start_index
Expand All @@ -917,15 +923,19 @@ define(['exports', 'aurelia-binding', 'aurelia-templating', 'aurelia-templating-
}
}
else {
if (new_range_start_index > old_range_start_index && old_range_end_index >= new_range_start_index && new_range_end_index >= old_range_end_index) {
if (new_range_start_index > old_range_start_index
&& old_range_end_index >= new_range_start_index
&& new_range_end_index >= old_range_end_index) {
var views_to_move_count = new_range_start_index - old_range_start_index;
this._moveViews(views_to_move_count, 1);
didMovedViews = 1;
if (strategy.isNearBottom(this, new_range_end_index)) {
scrolling_state |= 8;
}
}
else if (old_range_start_index > new_range_start_index && old_range_start_index <= new_range_end_index && old_range_end_index >= new_range_end_index) {
else if (old_range_start_index > new_range_start_index
&& old_range_start_index <= new_range_end_index
&& old_range_end_index >= new_range_end_index) {
var views_to_move_count = old_range_end_index - new_range_end_index;
this._moveViews(views_to_move_count, -1);
didMovedViews = 1;
Expand All @@ -945,18 +955,42 @@ define(['exports', 'aurelia-binding', 'aurelia-templating', 'aurelia-templating-
}
}
else {
console.warn('Scroll intersection not handled');
strategy.remeasure(this);
if (old_range_start_index !== new_range_start_index || old_range_end_index !== new_range_end_index) {
console.log("[!] Scroll intersection not handled. With indices: "
+ ("new [" + new_range_start_index + ", " + new_range_end_index + "] / old [" + old_range_start_index + ", " + old_range_end_index + "]"));
strategy.remeasure(this);
}
else {
console.log('[!] Scroll handled, and there\'s no changes');
}
}
}
if (didMovedViews === 1) {
this.$first = new_range_start_index;
strategy.updateBuffers(this, new_range_start_index);
}
if ((scrolling_state & (1 | 8)) === (1 | 8)
|| (scrolling_state & (2 | 4)) === (2 | 4)) {
if ((scrolling_state & 9) === 9
|| (scrolling_state & 6) === 6) {
this.getMore(new_range_start_index, (scrolling_state & 4) > 0, (scrolling_state & 8) > 0);
}
else {
var scroll_top_delta = current_scroller_info.scrollTop - prev_scroller_info.scrollTop;
scrolling_state = scroll_top_delta > 0
? 1
: scroll_top_delta < 0
? 2
: 0;
if (strategy.isNearTop(this, new_range_start_index)) {
scrolling_state |= 4;
}
if (strategy.isNearBottom(this, new_range_end_index)) {
scrolling_state |= 8;
}
if ((scrolling_state & 9) === 9
|| (scrolling_state & 6) === 6) {
this.getMore(new_range_start_index, (scrolling_state & 4) > 0, (scrolling_state & 8) > 0);
}
}
};
VirtualRepeat.prototype._moveViews = function (viewsCount, direction) {
var repeat = this;
Expand Down Expand Up @@ -1007,7 +1041,7 @@ define(['exports', 'aurelia-binding', 'aurelia-templating', 'aurelia-templating-
var scrollContext = {
topIndex: topIndex,
isAtBottom: isNearBottom,
isAtTop: isNearTop
isAtTop: isNearTop,
};
var overrideContext = _this.scope.overrideContext;
overrideContext.$scrollContext = scrollContext;
Expand Down Expand Up @@ -1205,7 +1239,7 @@ define(['exports', 'aurelia-binding', 'aurelia-templating', 'aurelia-templating-
InfiniteScrollNext.$resource = function () {
return {
type: 'attribute',
name: 'infinite-scroll-next'
name: 'infinite-scroll-next',
};
};
return InfiniteScrollNext;
Expand Down
17 changes: 11 additions & 6 deletions dist/aurelia-ui-virtualization.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,17 +115,22 @@ export interface IVirtualRepeater extends AbstractRepeater {
*/
updateBufferElements(skipUpdate?: boolean): void;
}
export interface IVirtualRepeatStrategy {
export declare type RepeatableValue = number | any[] | Map<any, any> | Set<any>;
export interface IVirtualRepeatStrategy<T extends RepeatableValue = RepeatableValue> {
/**
* create first item to calculate the heights
*/
createFirstRow(repeat: IVirtualRepeater): IView;
/**
* Count the number of the items in the repeatable value `items`
*/
count(items: T): number;
/**
* Calculate required variables for a virtual repeat instance to operate properly
*
* @returns `false` to notify that calculation hasn't been finished
*/
initCalculation(repeat: IVirtualRepeater, items: number | any[] | Map<any, any> | Set<any>): VirtualizationCalculation;
initCalculation(repeat: IVirtualRepeater, items: T): VirtualizationCalculation;
/**
* Handle special initialization if any, depends on different strategy
*/
Expand All @@ -151,23 +156,23 @@ export interface IVirtualRepeatStrategy {
/**
* Get the observer based on collection type of `items`
*/
getCollectionObserver(observerLocator: ObserverLocator, items: any[] | Map<any, any> | Set<any>): InternalCollectionObserver;
getCollectionObserver(observerLocator: ObserverLocator, items: T): InternalCollectionObserver;
/**
* @override
* Handle the repeat's collection instance changing.
* @param repeat The repeater instance.
* @param items The new array instance.
* @param firstIndex The index of first active view
*/
instanceChanged(repeat: IVirtualRepeater, items: any[] | Map<any, any> | Set<any>, firstIndex?: number): void;
instanceChanged(repeat: IVirtualRepeater, items: T, firstIndex?: number): void;
/**
* @override
* Handle the repeat's collection instance mutating.
* @param repeat The virtual repeat instance.
* @param array The modified array.
* @param items The modified array.
* @param splices Records of array changes.
*/
instanceMutated(repeat: IVirtualRepeater, array: any[], splices: ICollectionObserverSplice[]): void;
instanceMutated(repeat: IVirtualRepeater, items: RepeatableValue, splices: ICollectionObserverSplice[]): void;
/**
* Unlike normal repeat, virtualization repeat employs "padding" elements. Those elements
* often are just blank block with proper height/width to adjust the height/width/scroll feeling
Expand Down
Loading

0 comments on commit 54df50c

Please sign in to comment.