File tree Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -130,6 +130,11 @@ export default Base.extend({
130130        } ; 
131131
132132        const  gallery  =  new  PhotoSwipe ( pswp_el ,  PhotoSwipeUI ,  this . images ,  options ) ; 
133+ 
134+         const  gallery_reinit_sizes_debouncer  =  utils . debounce ( ( )  =>  { 
135+             gallery . updateSize ( true ) ;  // reinit Items 
136+         } ,  50 ) ; 
137+ 
133138        gallery . listen ( "gettingData" ,  function  ( index ,  item )  { 
134139            // Workaround for the fact that we don't know the image sizes. 
135140            // https://github.com/dimsemenov/PhotoSwipe/issues/796 
@@ -141,8 +146,8 @@ export default Base.extend({
141146                    // will get size after load 
142147                    item . w  =  img_el . width ;  // set image width 
143148                    item . h  =  img_el . height ;  // set image height 
144-                     gallery . invalidateCurrItems ( ) ;   // reinit Items 
145-                     gallery . updateSize ( true ) ;  // reinit Items  
149+                     item . needsUpdate   =   true ; 
150+                     gallery_reinit_sizes_debouncer ( ) ;  // debounce to not land in a re-init loop.  
146151                } ; 
147152                img . src  =  item . src ;  // let's download image 
148153            } 
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments