Skip to content
Source
Sign inSign up
TanStack/virtual

Adding keepAliveOnHidden option to keep items mounted in case of a tab switch, e.g., in ion-tabs. #1104

Openj4hangir(GitHub profile, opens in a new tab)wants to merge 4 commits intomain fromrefs/pull/1104/headopened

Showing 1 changed file with 16 additions and 0 deletions.

x
0 of 1 viewed, 1 left
16 additions and 0 deletionspackages/virtual-core/src/index.tsModified
View file
@@ -348,6 +348,7 @@
enabled?: boolean
isRtl?: boolean
useAnimationFrameWithResizeObserver?: boolean
+ keepAliveOnHidden?: boolean
​
export class Virtualizer<
@@ -447,6 +448,7 @@
isRtl: false,
useScrollendEvent: false,
useAnimationFrameWithResizeObserver: false,
+ keepAliveOnHidden: false,
...opts,
@@ -793,6 +795,14 @@
​
+ private isVisible = () => {
+ if (!this.scrollElement) return false
+ return (
+ this.scrollElement instanceof Window ||
+ (this.scrollElement as HTMLElement).offsetWidth > 0
+ )
+ }
+​