Skip to content

Commit

Permalink
chore(all): prepare release 1.0.0-beta.7
Browse files Browse the repository at this point in the history
  • Loading branch information
EisenbergEffect committed May 6, 2019
1 parent f858725 commit a0a9fb2
Show file tree
Hide file tree
Showing 12 changed files with 3,055 additions and 2,934 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "aurelia-ui-virtualization",
"version": "1.0.0-beta.6",
"version": "1.0.0-beta.7",
"description": "A plugin that provides a virtualized repeater and other virtualization services.",
"keywords": [
"aurelia",
Expand Down
720 changes: 353 additions & 367 deletions dist/amd/aurelia-ui-virtualization.js

Large diffs are not rendered by default.

228 changes: 220 additions & 8 deletions dist/aurelia-ui-virtualization.d.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,153 @@
import { ICollectionObserverSplice, InternalCollectionObserver, ObserverLocator, OverrideContext, Scope } from 'aurelia-binding';
import { Container } from 'aurelia-dependency-injection';
import { BoundViewFactory, TargetInstruction, View, ViewResources, ViewSlot } from 'aurelia-templating';
import { AbstractRepeater, RepeatStrategy } from 'aurelia-templating-resources';
import { AbstractRepeater } from 'aurelia-templating-resources';

export interface IScrollNextScrollContext {
topIndex: number;
isAtBottom: boolean;
isAtTop: boolean;
}
export interface IVirtualRepeatStrategy extends RepeatStrategy {
export interface IVirtualRepeater extends AbstractRepeater {
items: any;
local?: string;
/**
* First view index, for proper follow up calculations
*/
$first: number;
/**
* Defines how many items there should be for a given index to be considered at edge
*/
edgeDistance: number;
/**
* Template handling strategy for this repeat.
*/
templateStrategy: ITemplateStrategy;
/**
* The element hosting the scrollbar for this repeater
*/
scrollerEl: HTMLElement;
/**
* Bot buffer element, used to reflect the visualization of amount of items `after` the first visible item
*/
bottomBufferEl: HTMLElement;
/**
* Height of top buffer to properly push the visible rendered list items into right position
* Usually determined by `_first` visible index * `itemHeight`
*/
topBufferHeight: number;
/**
* Height of bottom buffer to properly push the visible rendered list items into right position
*/
bottomBufferHeight: number;
/**
* Height of each item. Calculated based on first item
*/
itemHeight: number;
/**
* Calculate current scrolltop position
*/
distanceToTop: number;
/**
* Number indicating minimum elements required to render to fill up the visible viewport
*/
minViewsRequired: number;
/**
* ViewSlot that encapsulates the repeater views operations in the template
*/
readonly viewSlot: ViewSlot;
/**
* Aurelia change handler by convention for property `items`. Used to properly determine action
* needed when items value has been changed
*/
itemsChanged(): void;
/**
* Get first visible view
*/
firstView(): IView | null;
/**
* Get last visible view
*/
lastView(): IView | null;
/**
* Get index of first visible view
*/
firstViewIndex(): number;
/**
* Get index of last visible view
*/
lastViewIndex(): number;
/**
* Virtual repeater normally employs scroll handling buffer for performance reasons.
* As syncing between scrolling state and visible views could be expensive.
*/
enableScroll(): void;
/**
* Invoke infinite scroll next function expression with currently bound scope of the repeater
*/
getMore(topIndex: number, isNearTop: boolean, isNearBottom: boolean, force?: boolean): void;
/**
* Get the real scroller element of the DOM tree this repeat resides in
*/
getScroller(): HTMLElement;
/**
* Get scrolling information of the real scroller element of the DOM tree this repeat resides in
*/
getScrollerInfo(): IScrollerInfo;
/**
* Observe scroller element to react upon sizing changes
*/
observeScroller(scrollerEl: HTMLElement): void;
/**
* Dispose scroller content size observer, if has
* Dispose all event listeners related to sizing of scroller, if any
*/
unobserveScroller(): void;
/**
* Signal the repeater to reset all its internal calculation states.
* Typically used when items value is null, undefined, empty collection.
* Or the repeater has been detached
*/
resetCalculation(): void;
/**
* Update buffer elements height/width with corresponding
* @param skipUpdate `true` to signal this repeater that the update won't trigger scroll event
*/
updateBufferElements(skipUpdate?: boolean): void;
}
export interface IVirtualRepeatStrategy {
/**
* create first item to calculate the heights
*/
createFirstItem(repeat: VirtualRepeat): IView;
createFirstRow(repeat: IVirtualRepeater): IView;
/**
* Calculate required variables for a virtual repeat instance to operate properly
*
* @returns `false` to notify that calculation hasn't been finished
*/
initCalculation(repeat: VirtualRepeat, items: number | any[] | Map<any, any> | Set<any>): VirtualizationCalculation;
initCalculation(repeat: IVirtualRepeater, items: number | any[] | Map<any, any> | Set<any>): VirtualizationCalculation;
/**
* Handle special initialization if any, depends on different strategy
*/
onAttached(repeat: IVirtualRepeater): void;
/**
* Calculate the start and end index of a repeat based on its container current scroll position
*/
getViewRange(repeat: IVirtualRepeater, scrollerInfo: IScrollerInfo): [number, number];
/**
* Returns true if first index is approaching start of the collection
* Virtual repeat can use this to invoke infinite scroll next
*/
isNearTop(repeat: IVirtualRepeater, firstIndex: number): boolean;
/**
* Returns true if last index is approaching end of the collection
* Virtual repeat can use this to invoke infinite scroll next
*/
isNearBottom(repeat: IVirtualRepeater, lastIndex: number): boolean;
/**
* Update repeat buffers height based on repeat.items
*/
updateBuffers(repeat: IVirtualRepeater, firstIndex: number): void;
/**
* Get the observer based on collection type of `items`
*/
Expand All @@ -30,15 +159,30 @@ export interface IVirtualRepeatStrategy extends RepeatStrategy {
* @param items The new array instance.
* @param firstIndex The index of first active view
*/
instanceChanged(repeat: VirtualRepeat, items: any[] | Map<any, any> | Set<any>, firstIndex?: number): void;
instanceChanged(repeat: IVirtualRepeater, items: any[] | Map<any, any> | Set<any>, firstIndex?: number): void;
/**
* @override
* Handle the repeat's collection instance mutating.
* @param repeat The virtual repeat instance.
* @param array The modified array.
* @param splices Records of array changes.
*/
instanceMutated(repeat: VirtualRepeat, array: any[], splices: ICollectionObserverSplice[]): void;
instanceMutated(repeat: IVirtualRepeater, array: any[], 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
* of virtualized repeat.
*
* Because of this, either mutation or change of the collection of repeat will potentially require
* readjustment (or measurement) of those blank block, based on scroll position
*
* This is 2 phases scroll handle
*/
remeasure(repeat: IVirtualRepeater): void;
/**
* Update all visible views of a repeater, starting from given `startIndex`
*/
updateAllViews(repeat: IVirtualRepeater, startIndex: number): void;
}
/**
* Templating strategy to handle virtual repeat views
Expand Down Expand Up @@ -82,6 +226,12 @@ export interface ITemplateStrategy {
* Override `bindingContext` and `overrideContext` on `View` interface
*/
export declare type IView = View & Scope;
/**
* Expose property `children` to help manipulation/calculation
*/
export declare type IViewSlot = ViewSlot & {
children: IView[];
};
/**
* Object with information about current state of a scrollable element
* Capturing:
Expand All @@ -91,7 +241,6 @@ export declare type IView = View & Scope;
*/
export interface IScrollerInfo {
scroller: HTMLElement;
scrollHeight: number;
scrollTop: number;
height: number;
}
Expand Down Expand Up @@ -127,7 +276,20 @@ declare class TemplateStrategyLocator {
*/
getStrategy(element: Element): ITemplateStrategy;
}
export declare class VirtualRepeat extends AbstractRepeater {
export declare class VirtualRepeat extends AbstractRepeater implements IVirtualRepeater {
/**
* First view index, for proper follow up calculations
*/
$first: number;
/**
* Height of top buffer to properly push the visible rendered list items into right position
* Usually determined by `_first` visible index * `itemHeight`
*/
topBufferHeight: number;
/**
* Height of bottom buffer to properly push the visible rendered list items into right position
*/
bottomBufferHeight: number;
key: any;
value: any;
/**
Expand All @@ -138,11 +300,43 @@ export declare class VirtualRepeat extends AbstractRepeater {
* @bindable
*/
local: string;
viewSlot: IViewSlot;
readonly viewFactory: BoundViewFactory;
/**
* Reference to scrolling container of this virtual repeat
* Usually determined by template strategy.
*
* The scrolling container may vary based on different position of `virtual-repeat` attribute
*/
scrollerEl: HTMLElement;
/**
* Defines how many items there should be for a given index to be considered at edge
*/
edgeDistance: number;
/**
* Template handling strategy for this repeat.
*/
templateStrategy: ITemplateStrategy;
/**
* Top buffer element, used to reflect the visualization of amount of items `before` the first visible item
*/
topBufferEl: HTMLElement;
/**
* Bot buffer element, used to reflect the visualization of amount of items `after` the first visible item
*/
bottomBufferEl: HTMLElement;
/**
* Height of each item. Calculated based on first item
*/
itemHeight: number;
/**
* Calculate current scrolltop position
*/
distanceToTop: number;
/**
* Number indicating minimum elements required to render to fill up the visible viewport
*/
minViewsRequired: number;
/**
* collection repeating strategy
*/
Expand Down Expand Up @@ -177,6 +371,7 @@ export declare class VirtualRepeat extends AbstractRepeater {
handleCollectionMutated(collection: any[], changes: ICollectionObserverSplice[]): void;
/**@override */
handleInnerCollectionMutated(collection: any[], changes: ICollectionObserverSplice[]): void;
enableScroll(): void;
/**
* Get the real scroller element of the DOM tree this repeat resides in
*/
Expand All @@ -185,6 +380,22 @@ export declare class VirtualRepeat extends AbstractRepeater {
* Get scrolling information of the real scroller element of the DOM tree this repeat resides in
*/
getScrollerInfo(): IScrollerInfo;
resetCalculation(): void;
getMore(topIndex: number, isNearTop: boolean, isNearBottom: boolean, force?: boolean): void;
updateBufferElements(skipUpdate?: boolean): void;
firstView(): IView | null;
lastView(): IView | null;
firstViewIndex(): number;
lastViewIndex(): number;
/**
* Observe scroller element to react upon sizing changes
*/
observeScroller(scrollerEl: HTMLElement): void;
/**
* Dispose scroller content size observer, if has
* Dispose all event listeners related to sizing of scroller, if any
*/
unobserveScroller(): void;
/**@override */
viewCount(): number;
/**@override */
Expand All @@ -199,6 +410,7 @@ export declare class VirtualRepeat extends AbstractRepeater {
removeAllViews(returnToCache: boolean, skipAnimation: boolean): void | Promise<void>;
/**@override */
removeView(index: number, returnToCache: boolean, skipAnimation: boolean): IView | Promise<IView>;
/**@override */
updateBindings(view: IView): void;
}
export declare class InfiniteScrollNext {
Expand Down
Loading

0 comments on commit a0a9fb2

Please sign in to comment.