Skip to content

Commit

Permalink
Merge pull request #66 from ValeryYafremau/JS-339
Browse files Browse the repository at this point in the history
JS-339: [SwatchRenderer.js] Preload images for all available options
  • Loading branch information
uharbachou1 committed Dec 7, 2015
2 parents e0efae1 + 76a5545 commit b581b35
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion app/code/Magento/Swatches/view/frontend/web/js/SwatchRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
define([
'jquery',
'underscore',
'mage/gallery/preloadImages',
'jquery/ui'
], function ($, _) {
], function ($, _, preloadImages) {
'use strict';

/**
Expand Down Expand Up @@ -268,6 +269,27 @@ define([
'img': $main.find('.product-image-photo').attr('src')
}];
}
this._preloadSwatchesImages();
},

/**
* Preloads optional configuration images.
* @private
*/
_preloadSwatchesImages: function () {
var options = this.options;

_.each(options.jsonConfig.images, function (array) {
var fullImagesList = [],
imagesList = [];

_.each(array, function (item) {
imagesList.push(item.img);
fullImagesList.push(item.full);
});
preloadImages(imagesList);
preloadImages(fullImagesList);
});
},

/**
Expand Down

0 comments on commit b581b35

Please sign in to comment.