Skip to content

Commit f90ea29

Browse files
committed
fix(infinite-scroll): prevent locking sibling min height while it's already locked, prevent useless setTimeout from being set up while preserve rerender scroll property isn't set
1 parent f9e7dcd commit f90ea29

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

core/src/components/infinite-scroll/infinite-scroll.tsx

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -141,13 +141,14 @@ export class InfiniteScroll implements ComponentInterface {
141141

142142
if (distanceFromInfinite < 0) {
143143
if (!this.didFire) {
144+
if (!this.isLoading && this.preserveRerenderScrollPosition) {
145+
// Lock the min height of the siblings of the infinite scroll
146+
// if we are preserving the rerender scroll position
147+
this.lockSiblingMinHeight(true);
148+
}
149+
144150
this.isLoading = true;
145151
this.didFire = true;
146-
147-
// Lock the min height of the siblings of the infinite scroll
148-
// if we are preserving the rerender scroll position
149-
this.lockSiblingMinHeight(true);
150-
151152
this.ionInfinite.emit();
152153
return 3;
153154
}
@@ -166,10 +167,6 @@ export class InfiniteScroll implements ComponentInterface {
166167
* has been previously set by the user when we restore after complete is called.
167168
*/
168169
private lockSiblingMinHeight(lock: boolean) {
169-
if (!this.preserveRerenderScrollPosition) {
170-
return;
171-
}
172-
173170
// Loop through all the siblings of the infinite scroll, but ignore the infinite scroll itself
174171
const siblings = this.el.parentElement?.children || [];
175172
for (const sibling of siblings) {
@@ -257,9 +254,11 @@ export class InfiniteScroll implements ComponentInterface {
257254

258255
// Unlock the min height of the siblings of the infinite scroll
259256
// if we are preserving the rerender scroll position
260-
setTimeout(() => {
261-
this.lockSiblingMinHeight(false);
262-
}, 100);
257+
if (this.preserveRerenderScrollPosition) {
258+
setTimeout(() => {
259+
this.lockSiblingMinHeight(false);
260+
}, 100);
261+
}
263262
}
264263

265264
private canStart(): boolean {

0 commit comments

Comments
 (0)