@@ -65,6 +65,20 @@ export default Base.extend({
6565        return  template ; 
6666    } , 
6767
68+     pswp_options ( )  { 
69+         return  { 
70+             scaleMode : this . options . scaleMethod , 
71+             loop : this . options . loop , 
72+             slideshowDelay : this . options . delay , 
73+             hideAnimationDuration : this . options . effectDuration , 
74+             showAnimationDuration : this . options . effectDuration , 
75+             pinchToClose : false , 
76+             closeOnScroll : false , 
77+             // Fix reload on gallery close which was induced by a history back call. 
78+             history : false , 
79+         } ; 
80+     } , 
81+ 
6882    initialize_trigger ( )  { 
6983        const  image_wrapper_els  =  dom . querySelectorAllAndMe ( 
7084            this . el , 
@@ -108,28 +122,18 @@ export default Base.extend({
108122        // Now - when all is set - prevent default action. 
109123        e . preventDefault ( ) ; 
110124
125+         // Get the index of the clicked gallery item in the list of images. 
111126        const  index  = 
112127            this . images 
113128                . map ( ( it )  =>  it . src ) 
114129                . indexOf ( 
115130                    trigger_el . getAttribute ( "href" )  ||  trigger_el . getAttribute ( "src" ) 
116131                )  ||  0 ; 
117132
118-         const  options  =  { 
119-             // Get the index of the clicked gallery item in the list of images. 
120-             index : index , 
121-             scaleMode : this . options . scaleMethod , 
122-             loop : this . options . loop , 
123-             slideshowDelay : this . options . delay , 
124-             hideAnimationDuration : this . options . effectDuration , 
125-             showAnimationDuration : this . options . effectDuration , 
126-             pinchToClose : false , 
127-             closeOnScroll : false , 
128-             // Fix reload on gallery close which was induced by a history back call. 
129-             history : false , 
130-         } ; 
133+         const  pswp_options  =  this . pswp_options ( ) ; 
134+         pswp_options . index  =  index ;  // start at clicked image 
131135
132-         const  gallery  =  new  PhotoSwipe ( pswp_el ,  PhotoSwipeUI ,  this . images ,  options ) ; 
136+         const  gallery  =  new  PhotoSwipe ( pswp_el ,  PhotoSwipeUI ,  this . images ,  pswp_options ) ; 
133137
134138        const  gallery_reinit_sizes_debouncer  =  utils . debounce ( ( )  =>  { 
135139            gallery . updateSize ( true ) ;  // reinit Items 
0 commit comments