File tree 1 file changed +23
-1
lines changed
app/code/Magento/Swatches/view/frontend/web/js
1 file changed +23
-1
lines changed Original file line number Diff line number Diff line change 6
6
define ( [
7
7
'jquery' ,
8
8
'underscore' ,
9
+ 'mage/gallery/preloadImages' ,
9
10
'jquery/ui'
10
- ] , function ( $ , _ ) {
11
+ ] , function ( $ , _ , preloadImages ) {
11
12
'use strict' ;
12
13
13
14
/**
@@ -268,6 +269,27 @@ define([
268
269
'img' : $main . find ( '.product-image-photo' ) . attr ( 'src' )
269
270
} ] ;
270
271
}
272
+ this . _preloadSwatchesImages ( ) ;
273
+ } ,
274
+
275
+ /**
276
+ * Preloads optional configuration images.
277
+ * @private
278
+ */
279
+ _preloadSwatchesImages : function ( ) {
280
+ var options = this . options ;
281
+
282
+ _ . each ( options . jsonConfig . images , function ( array ) {
283
+ var fullImagesList = [ ] ,
284
+ imagesList = [ ] ;
285
+
286
+ _ . each ( array , function ( item ) {
287
+ imagesList . push ( item . img ) ;
288
+ fullImagesList . push ( item . full ) ;
289
+ } ) ;
290
+ preloadImages ( imagesList ) ;
291
+ preloadImages ( fullImagesList ) ;
292
+ } ) ;
271
293
} ,
272
294
273
295
/**
You can’t perform that action at this time.
0 commit comments