@@ -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
+ $placeholderImage = $element . find ( '.gallery-placeholder__image' ) ,
276
+ $fotoramaElement ;
274
277
275
278
if ( settings . breakpoints ) {
276
279
_ . each ( _ . values ( settings . breakpoints ) , function ( breakpoint ) {
@@ -285,23 +288,40 @@ 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
+ // Adjust wrapper and placeholder styling just before initializing the gallery.
301
+ $placeholderImage . css ( {
302
+ position : 'absolute' ,
303
+ left : '50%' ,
304
+ transform : 'translateX(-50%)'
305
+ } ) ;
306
+ $element
307
+ . css ( 'min-height' , settings . $element . height ( ) )
308
+ . append ( tpl ) ;
309
+
310
+ $fotoramaElement = $element . find ( '[data-gallery-role="gallery"]' ) ;
311
+ $fotoramaElement . fotorama ( config ) ;
312
+ $fotoramaElement . find ( '.fotorama__stage__frame.fotorama__active' )
313
+ . one ( 'f:load' , function ( ) {
314
+ // Remove placeholder when main gallery image loads.
315
+ $placeholderImage . remove ( ) ;
316
+ $element
317
+ . removeClass ( '_block-content-loading' )
318
+ . css ( 'min-height' , '' ) ;
319
+ } ) ;
320
+ settings . fotoramaApi = $fotoramaElement . data ( 'fotorama' ) ;
321
+
301
322
$ . extend ( true , config , this . startConfig ) ;
302
323
303
324
mainImageIndex = getMainImageIndex ( config . data ) ;
304
-
305
325
if ( mainImageIndex ) {
306
326
this . settings . fotoramaApi . show ( {
307
327
index : mainImageIndex ,
0 commit comments