Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 112a299

Browse files
committed
fix(template): virtual-for: properly calculate stable state
1 parent bb7d903 commit 112a299

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

libs/template/experimental/virtual-scrolling/src/lib/scroll-strategies/autosize-virtual-scroll-strategy.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -359,8 +359,11 @@ export class AutoSizeVirtualScrollStrategy<
359359
}
360360

361361
private scrollTo(scrollTo: number, behavior?: ScrollBehavior): void {
362-
this.waitForScroll = true;
363-
this.isStable$.next(false);
362+
this.waitForScroll =
363+
scrollTo !== this.scrollTop && this.contentSize > this.containerSize;
364+
if (this.waitForScroll) {
365+
this.isStable$.next(false);
366+
}
364367
this.viewport!.scrollTo(this.viewportOffset + scrollTo, behavior);
365368
}
366369

libs/template/experimental/virtual-scrolling/src/lib/scroll-strategies/dynamic-size-virtual-scroll-strategy.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -284,8 +284,11 @@ export class DynamicSizeVirtualScrollStrategy<
284284
for (let i = 0; i < _index; i++) {
285285
scrollTo += this._virtualItems[i].size;
286286
}
287-
this.waitForScroll = true;
288-
this.isStable$.next(false);
287+
this.waitForScroll =
288+
scrollTo !== this.scrollTop && this.contentSize > this.containerSize;
289+
if (this.waitForScroll) {
290+
this.isStable$.next(false);
291+
}
289292
this.viewport!.scrollTo(this.viewportOffset + scrollTo, behavior);
290293
}
291294

0 commit comments

Comments
 (0)