File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -176,11 +176,22 @@ export class ZoomPanPinch {
176176 if ( centerOnInit ) {
177177 this . setCenter ( ) ;
178178 this . observer = new ResizeObserver ( ( ) => {
179- this . onInitCallbacks . forEach ( ( callback ) => callback ( getContext ( this ) ) ) ;
180- this . setCenter ( ) ;
181- this . observer ?. disconnect ( ) ;
179+ const currentWidth = contentComponent . offsetWidth ;
180+ const currentHeight = contentComponent . offsetHeight ;
181+
182+ if ( currentWidth > 0 || currentHeight > 0 ) {
183+ this . onInitCallbacks . forEach ( ( callback ) => callback ( getContext ( this ) ) ) ;
184+ this . setCenter ( ) ;
185+
186+ this . observer ?. disconnect ( ) ;
187+ }
182188 } ) ;
183189
190+ // if nothing about the contentComponent has changed after 5 seconds, disconnect the observer
191+ setTimeout ( ( ) => {
192+ this . observer ?. disconnect ( ) ;
193+ } , 5000 ) ;
194+
184195 // Start observing the target node for configured mutations
185196 this . observer . observe ( contentComponent ) ;
186197 }
You can’t perform that action at this time.
0 commit comments