diff --git a/src/js/gallery.js b/src/js/gallery.js index f73d68c7..6727c6a3 100644 --- a/src/js/gallery.js +++ b/src/js/gallery.js @@ -20,6 +20,7 @@ $.magnificPopup.registerModule('gallery', { enabled: false, arrowMarkup: '', preload: [0,2], + preloadAfterLoad: false, navigateByImgClick: true, arrows: true, @@ -89,14 +90,21 @@ $.magnificPopup.registerModule('gallery', { }); _mfpOn(CHANGE_EVENT+ns, function() { - if(mfp._preloadTimeout) clearTimeout(mfp._preloadTimeout); + if (!gSt.preloadAfterLoad) { + if(mfp._preloadTimeout) clearTimeout(mfp._preloadTimeout); - mfp._preloadTimeout = setTimeout(function() { - mfp.preloadNearbyImages(); - mfp._preloadTimeout = null; - }, 16); + mfp._preloadTimeout = setTimeout(function() { + mfp.preloadNearbyImages(); + mfp._preloadTimeout = null; + }, 16); + } }); + _mfpOn('ImageLoadComplete', function() { + if (gSt.preloadAfterLoad) { + mfp.preloadNearbyImages(); + } + }); _mfpOn(CLOSE_EVENT+ns, function() { _document.off(ns); @@ -161,4 +169,4 @@ $.magnificPopup.registerModule('gallery', { item.preloaded = true; } } -}); \ No newline at end of file +});