Skip to content

Commit 807ef0b

Browse files
MKirovaMKirova
authored andcommitted
chore(*): Use resize observer only for measurements.
1 parent 2d96c12 commit 807ef0b

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

projects/igniteui-angular/directives/src/directives/for-of/for_of.directive.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -501,6 +501,7 @@ export class IgxForOfDirective<T, U extends T[] = T[]> extends IgxForOfToken<T,U
501501
protected subscribeToObserver(target: Element) {
502502
if (this.igxForScrollOrientation === 'vertical') {
503503
this._zone.runOutsideAngular(() => {
504+
// console.log(target);
504505
if (this.platformUtil.isBrowser) {
505506
this.contentObserver = new (getResizeObserver())((entries: ResizeObserverEntry[]) => this.contentResizeNotify.next(entries));
506507
this.contentObserver.observe(target);
@@ -842,11 +843,16 @@ export class IgxForOfDirective<T, U extends T[] = T[]> extends IgxForOfToken<T,U
842843
continue;
843844
}
844845
const currDiff = newVal - oldVal;
846+
// if (currDiff > 0) {
847+
// console.log('RECALC Size increased for index ', targetIndex, ' from ', oldVal, ' to ', newVal);
848+
// }
845849
diffs.push(currDiff);
846850
totalDiff += currDiff;
847851
this.individualSizeCache[targetIndex] = cachedNodeSize;
848852
this.sizesCache[targetIndex + 1] = (this.sizesCache[targetIndex] || 0) + newVal;
849853
}
854+
855+
// console.log(this.individualSizeCache);
850856
// update cache
851857
if (Math.abs(totalDiff) > 0) {
852858
for (let j = this.state.startIndex + this.state.chunkSize + 1; j < this.sizesCache.length; j++) {
@@ -958,22 +964,15 @@ export class IgxForOfDirective<T, U extends T[] = T[]> extends IgxForOfToken<T,U
958964
}
959965

960966
protected updateSizes(entries:ResizeObserverEntry[] ) {
961-
if (!this.scrollComponent.nativeElement.isConnected) return;
962-
const scrollable = this.isScrollable();
963967
entries.forEach((entry) => {
964968
const index = parseInt(entry.target.getAttribute('data-index'), 0);
965969
const height = entry.contentRect.height;
966970
const embView = this._embeddedViews[index - this.state.startIndex];
967971
this._embeddedViewSizesCache.set(embView, height);
972+
// console.log('Observed size change for index ', index, ' new size ', height);
973+
// console.log(this._embeddedViewSizesCache);
968974
});
969-
this._applyChanges();
970-
this._updateScrollOffset();
971975
this.recalcUpdateSizes();
972-
if (scrollable !== this.isScrollable()) {
973-
this.scrollbarVisibilityChanged.emit();
974-
} else {
975-
this.contentSizeChange.emit();
976-
}
977976
}
978977

979978
/**
@@ -1423,6 +1422,7 @@ export class IgxForOfDirective<T, U extends T[] = T[]> extends IgxForOfToken<T,U
14231422
// also detach from ViewContainerRef to make absolutely sure this is removed from the view container.
14241423
this.dc.instance._vcr.detach(this.dc.instance._vcr.length - 1);
14251424
oldElem.destroy();
1425+
this._embeddedViewSizesCache.delete(oldElem);
14261426

14271427
this.state.chunkSize--;
14281428
}

0 commit comments

Comments
 (0)