Skip to content

Commit

Permalink
Fixed #11771 - Table: VirtualScroll not detecting changes of data
Browse files Browse the repository at this point in the history
  • Loading branch information
mertsincan committed Aug 9, 2022
1 parent 62144ec commit d0626b1
Showing 1 changed file with 11 additions and 14 deletions.
25 changes: 11 additions & 14 deletions src/app/components/scroller/scroller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -307,29 +307,26 @@ export class Scroller implements OnInit, AfterContentInit, AfterViewChecked, OnD
}

ngOnChanges(simpleChanges: SimpleChanges) {
if (this.initialized) {
let areItemsChanged = false;
if (simpleChanges.items) {
const { previousValue: prevItems, currentValue: currentItems } = simpleChanges.items;
areItemsChanged = !prevItems || prevItems.length !== (currentItems || []).length;
}

const isChanged = (areItemsChanged || simpleChanges.itemSize || simpleChanges.scrollHeight || simpleChanges.scrollWidth);
isChanged && this.init();
}

if (simpleChanges.orientation) {
this.lastScrollPos = this.both ? { top: 0, left: 0 } : 0;
}
let isLoadingChanged = false;

if (simpleChanges.loading) {
const { previousValue, currentValue } = simpleChanges.loading;

if (this.lazy && previousValue !== currentValue && currentValue !== this.d_loading) {
this.d_loading = currentValue;
isLoadingChanged = true;
}
}

if (this.initialized) {
const isChanged = !isLoadingChanged && (simpleChanges.items || simpleChanges.itemSize || simpleChanges.scrollHeight || simpleChanges.scrollWidth);
isChanged && this.init();
}

if (simpleChanges.orientation) {
this.lastScrollPos = this.both ? { top: 0, left: 0 } : 0;
}

if (simpleChanges.numToleratedItems) {
const { previousValue, currentValue } = simpleChanges.numToleratedItems;

Expand Down

0 comments on commit d0626b1

Please sign in to comment.