@@ -270,7 +270,10 @@ define([
270
270
next : $t ( 'Next' ) ,
271
271
previous : $t ( 'Previous' )
272
272
} ) ,
273
- mainImageIndex ;
273
+ mainImageIndex ,
274
+ $element = settings . $element ,
275
+ $fotoramaElement ,
276
+ $fotoramaStage ;
274
277
275
278
if ( settings . breakpoints ) {
276
279
_ . each ( _ . values ( settings . breakpoints ) , function ( breakpoint ) {
@@ -285,19 +288,38 @@ define([
285
288
settings . breakpoints = breakpoints ;
286
289
}
287
290
288
- _ . extend ( config , config . options ) ;
289
- config . options = undefined ;
290
-
291
- config . click = false ;
292
- config . breakpoints = null ;
291
+ _ . extend ( config , config . options ,
292
+ {
293
+ options : undefined ,
294
+ click : false ,
295
+ breakpoints : null
296
+ }
297
+ ) ;
293
298
settings . currentConfig = config ;
294
- settings . $element . css ( 'min-height' , settings . $element . height ( ) ) ;
295
- settings . $element . html ( tpl ) ;
296
- settings . $element . removeClass ( '_block-content-loading' ) ;
297
- settings . $elementF = $ ( settings . $element . children ( ) [ 0 ] ) ;
298
- settings . $elementF . fotorama ( config ) ;
299
- settings . $element . css ( 'min-height' , '' ) ;
300
- settings . fotoramaApi = settings . $elementF . data ( 'fotorama' ) ;
299
+
300
+ $element
301
+ . css ( 'min-height' , settings . $element . height ( ) )
302
+ . append ( tpl ) ;
303
+
304
+ $fotoramaElement = $element . find ( '[data-gallery-role="gallery"]' ) ;
305
+
306
+ $fotoramaStage = $fotoramaElement . find ( '.fotorama__stage' ) ;
307
+ $fotoramaStage . css ( 'position' , 'absolute' ) ;
308
+
309
+ $fotoramaElement . fotorama ( config ) ;
310
+ $fotoramaElement . find ( '.fotorama__stage__frame.fotorama__active' )
311
+ . one ( 'f:load' , function ( ) {
312
+ // Remove placeholder when main gallery image loads.
313
+ $element . find ( '.gallery-placeholder__image' ) . remove ( ) ;
314
+ $element
315
+ . removeClass ( '_block-content-loading' )
316
+ . css ( 'min-height' , '' ) ;
317
+
318
+ $fotoramaStage . css ( 'position' , '' ) ;
319
+ } ) ;
320
+ settings . $elementF = $fotoramaElement ;
321
+ settings . fotoramaApi = $fotoramaElement . data ( 'fotorama' ) ;
322
+
301
323
$ . extend ( true , config , this . startConfig ) ;
302
324
303
325
mainImageIndex = getMainImageIndex ( config . data ) ;
0 commit comments