File tree Expand file tree Collapse file tree 1 file changed +10
-1
lines changed
Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -121,6 +121,8 @@ export class List<T, VH extends ViewHolder<T>> implements ClassComponent<ListAtt
121121 private activeIndex : number | null = null
122122 private lastThemeId : ThemeId = theme . themeId
123123
124+ private observer : ResizeObserver | null = null
125+
124126 view ( { attrs } : Vnode < ListAttrs < T , VH > > ) {
125127 const oldRenderConfig = this . lastAttrs ?. renderConfig
126128 this . lastAttrs = attrs
@@ -134,7 +136,9 @@ export class List<T, VH extends ViewHolder<T>> implements ClassComponent<ListAtt
134136 // Some of the tech-savvy users like to disable *all* "experimental features" in their Safari devices and there's also a toggle to disable
135137 // ResizeObserver. Since the app works without it anyway we just fall back to not handling the resize events.
136138 if ( typeof ResizeObserver !== "undefined" ) {
137- createResizeObserver ( ( ) => this . updateSize ( ) ) . observe ( this . containerDom )
139+ this . observer ?. disconnect ( )
140+ this . observer = createResizeObserver ( ( ) => this . updateSize ( ) )
141+ this . observer . observe ( this . containerDom )
138142 } else {
139143 requestAnimationFrame ( ( ) => this . updateSize ( ) )
140144 }
@@ -182,6 +186,11 @@ export class List<T, VH extends ViewHolder<T>> implements ClassComponent<ListAtt
182186 )
183187 }
184188
189+ onremove ( ) : any {
190+ this . observer ?. disconnect ( )
191+ this . observer = null
192+ }
193+
185194 private createSwipeHandler ( ) {
186195 return new ListSwipeHandler < T , VH > ( this . containerDom ! , {
187196 width : ( ) => this . width ,
You can’t perform that action at this time.
0 commit comments