Permalink
Browse files

fix(virtual-repeat): remove buffer size

  • Loading branch information...
bigopon committed Jan 15, 2019
1 parent 57cd66d commit c9de65b8c9ceff54b9b63e792201a4cb872462db
Showing with 162 additions and 90 deletions.
  1. +15 −11 src/array-virtual-repeat-strategy.ts
  2. +1 −1 src/dom-helper.ts
  3. +1 −1 src/interfaces.ts
  4. +145 −77 src/virtual-repeat.ts
@@ -22,13 +22,25 @@ export class ArrayVirtualRepeatStrategy extends ArrayRepeatStrategy implements I
this._inPlaceProcessItems(repeat, items, rest[0]);
}

/**
* Handle the repeat's collection instance mutating.
* @param repeat The repeat instance.
* @param array The modified array.
* @param splices Records of array changes.
*/
instanceMutated(repeat: IVirtualRepeat, array: Array<any>, splices: any): void {
this._standardProcessInstanceMutated(repeat, array, splices);
}

/**@internal */
_standardProcessInstanceChanged(repeat: IVirtualRepeat, items: Array<any>): void {
for (let i = 1, ii = repeat._viewsLength; i < ii; ++i) {
let overrideContext = createFullOverrideContext(repeat, items[i], i, ii);
repeat.addView(overrideContext.bindingContext, overrideContext);
}
}

/**@internal */
_inPlaceProcessItems(repeat: IVirtualRepeat, items: Array<any>, first: number): void {
let itemsLength = items.length;
let viewsLength = repeat.viewCount();
@@ -71,16 +83,7 @@ export class ArrayVirtualRepeatStrategy extends ArrayRepeatStrategy implements I
}
}

/**
* Handle the repeat's collection instance mutating.
* @param repeat The repeat instance.
* @param array The modified array.
* @param splices Records of array changes.
*/
instanceMutated(repeat: IVirtualRepeat, array: Array<any>, splices: any): void {
this._standardProcessInstanceMutated(repeat, array, splices);
}

/**@internal */
_standardProcessInstanceMutated(repeat: IVirtualRepeat, array: Array<any>, splices: any): void {
if (repeat.__queuedSplices) {
for (let i = 0, ii = splices.length; i < ii; ++i) {
@@ -110,6 +113,7 @@ export class ArrayVirtualRepeatStrategy extends ArrayRepeatStrategy implements I
}
}

/**@internal */
_runSplices(repeat: IVirtualRepeat, array: Array<any>, splices: any): any {
let removeDelta = 0;
let rmPromises = [];
@@ -185,7 +189,7 @@ export class ArrayVirtualRepeatStrategy extends ArrayRepeatStrategy implements I
viewOrPromise = repeat.removeView(viewIndex, returnToCache);
if (repeat.items.length > viewCount) {
// TODO: do not trigger view lifecycle here
let collectionAddIndex;
let collectionAddIndex: number;
if (repeat._bottomBufferHeight > repeat.itemHeight) {
viewAddIndex = viewCount;
if (!removeMoreThanInDom) {
@@ -4,7 +4,7 @@ export class DomHelper {
let documentElement = document.documentElement;
let scrollTop = window.pageYOffset;
let clientTop = documentElement.clientTop;
let top = box.top + scrollTop - clientTop;
let top = box.top + scrollTop - clientTop;
return Math.round(top);
}

@@ -1,6 +1,6 @@
import { Repeat, RepeatStrategy } from 'aurelia-templating-resources';
import { ViewSlot, View, ViewFactory, BoundViewFactory, Controller } from 'aurelia-templating';
import { Scope, Binding } from 'aurelia-binding';
import { Scope, Binding, OverrideContext } from 'aurelia-binding';
import { TaskQueue } from 'aurelia-task-queue';

/**@internal */
Oops, something went wrong.

0 comments on commit c9de65b

Please sign in to comment.