lazysizes
Advanced tools
Comparing version 4.1.6 to 4.1.7
@@ -309,6 +309,2 @@ (function(window, factory) { | ||
isLoading--; | ||
if(e && e.target){ | ||
addRemoveLoadEvents(e.target, resetPreloading); | ||
} | ||
if(!e || isLoading < 0 || !e.target){ | ||
@@ -368,2 +364,4 @@ isLoading = 0; | ||
lazysizes._defEx = defaultExpand; | ||
preloadExpand = defaultExpand * lazySizesConfig.expFactor; | ||
@@ -428,6 +426,14 @@ hFac = lazySizesConfig.hFac; | ||
var switchLoadingClass = function(e){ | ||
addClass(e.target, lazySizesConfig.loadedClass); | ||
removeClass(e.target, lazySizesConfig.loadingClass); | ||
addRemoveLoadEvents(e.target, rafSwitchLoadingClass); | ||
triggerEvent(e.target, 'lazyloaded'); | ||
var elem = e.target; | ||
if (elem._lazyCache) { | ||
delete elem._lazyCache; | ||
return; | ||
} | ||
resetPreloading(e); | ||
addClass(elem, lazySizesConfig.loadedClass); | ||
removeClass(elem, lazySizesConfig.loadingClass); | ||
addRemoveLoadEvents(elem, rafSwitchLoadingClass); | ||
triggerEvent(elem, 'lazyloaded'); | ||
}; | ||
@@ -486,8 +492,7 @@ var rafedSwitchLoadingClass = rAFIt(switchLoadingClass); | ||
addClass(elem, lazySizesConfig.loadingClass); | ||
if(firesLoad){ | ||
addRemoveLoadEvents(elem, resetPreloading, true); | ||
clearTimeout(resetPreloadingTimer); | ||
resetPreloadingTimer = setTimeout(resetPreloading, 2500); | ||
addClass(elem, lazySizesConfig.loadingClass); | ||
addRemoveLoadEvents(elem, rafSwitchLoadingClass, true); | ||
@@ -521,9 +526,11 @@ } | ||
rAF(function(){ | ||
// Part of this can be removed as soon as this fix is older: https://bugs.chromium.org/p/chromium/issues/detail?id=7731 (2015) | ||
if( !firesLoad || (elem.complete && elem.naturalWidth > 1)){ | ||
if(firesLoad){ | ||
resetPreloading(event); | ||
} else { | ||
isLoading--; | ||
} | ||
switchLoadingClass(event); | ||
elem._lazyCache = true; | ||
setTimeout(function(){ | ||
if ('_lazyCache' in elem) { | ||
delete elem._lazyCache; | ||
} | ||
}, 9); | ||
} | ||
@@ -530,0 +537,0 @@ }, true); |
@@ -306,6 +306,2 @@ (function(window, factory) { | ||
isLoading--; | ||
if(e && e.target){ | ||
addRemoveLoadEvents(e.target, resetPreloading); | ||
} | ||
if(!e || isLoading < 0 || !e.target){ | ||
@@ -365,2 +361,4 @@ isLoading = 0; | ||
lazysizes._defEx = defaultExpand; | ||
preloadExpand = defaultExpand * lazySizesConfig.expFactor; | ||
@@ -425,6 +423,14 @@ hFac = lazySizesConfig.hFac; | ||
var switchLoadingClass = function(e){ | ||
addClass(e.target, lazySizesConfig.loadedClass); | ||
removeClass(e.target, lazySizesConfig.loadingClass); | ||
addRemoveLoadEvents(e.target, rafSwitchLoadingClass); | ||
triggerEvent(e.target, 'lazyloaded'); | ||
var elem = e.target; | ||
if (elem._lazyCache) { | ||
delete elem._lazyCache; | ||
return; | ||
} | ||
resetPreloading(e); | ||
addClass(elem, lazySizesConfig.loadedClass); | ||
removeClass(elem, lazySizesConfig.loadingClass); | ||
addRemoveLoadEvents(elem, rafSwitchLoadingClass); | ||
triggerEvent(elem, 'lazyloaded'); | ||
}; | ||
@@ -483,8 +489,7 @@ var rafedSwitchLoadingClass = rAFIt(switchLoadingClass); | ||
addClass(elem, lazySizesConfig.loadingClass); | ||
if(firesLoad){ | ||
addRemoveLoadEvents(elem, resetPreloading, true); | ||
clearTimeout(resetPreloadingTimer); | ||
resetPreloadingTimer = setTimeout(resetPreloading, 2500); | ||
addClass(elem, lazySizesConfig.loadingClass); | ||
addRemoveLoadEvents(elem, rafSwitchLoadingClass, true); | ||
@@ -518,9 +523,11 @@ } | ||
rAF(function(){ | ||
// Part of this can be removed as soon as this fix is older: https://bugs.chromium.org/p/chromium/issues/detail?id=7731 (2015) | ||
if( !firesLoad || (elem.complete && elem.naturalWidth > 1)){ | ||
if(firesLoad){ | ||
resetPreloading(event); | ||
} else { | ||
isLoading--; | ||
} | ||
switchLoadingClass(event); | ||
elem._lazyCache = true; | ||
setTimeout(function(){ | ||
if ('_lazyCache' in elem) { | ||
delete elem._lazyCache; | ||
} | ||
}, 9); | ||
} | ||
@@ -527,0 +534,0 @@ }, true); |
{ | ||
"name": "lazysizes", | ||
"version": "4.1.6", | ||
"version": "4.1.7", | ||
"filename": "lazysizes.min.js", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -20,3 +20,3 @@ (function(window, factory) { | ||
var slice = [].slice; | ||
var regBlurUp = /blur-up["']*\s*:\s*["']*(always|auto|unobtrusive)/; | ||
var regBlurUp = /blur-up["']*\s*:\s*["']*(always|auto)/; | ||
var regType = /image\/(jpeg|png|gif|svg\+xml)/; | ||
@@ -140,27 +140,22 @@ var transSrc = 'data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=='; | ||
var parentUnveil = function (e) { | ||
if(parent != e.target){ | ||
return; | ||
} | ||
if(blurUp == 'unobtrusive'){ | ||
lazySizes.aC(blurImg || img, 'ls-inview'); | ||
setStateUp(); | ||
} else { | ||
var parentUnveil = function (e) { | ||
if(parent != e.target){ | ||
return; | ||
} | ||
lazySizes.aC(blurImg || img, 'ls-inview'); | ||
parent.removeEventListener('lazybeforeunveil', parentUnveil); | ||
}; | ||
setStateUp(); | ||
if(!parent.getAttribute('data-expand')){ | ||
parent.setAttribute('data-expand', -1); | ||
} | ||
parent.removeEventListener('lazybeforeunveil', parentUnveil); | ||
}; | ||
parent.addEventListener('lazybeforeunveil', parentUnveil); | ||
if(!parent.getAttribute('data-expand')){ | ||
parent.setAttribute('data-expand', -1); | ||
} | ||
lazySizes.aC(parent, lazySizes.cfg.lazyClass); | ||
parent.addEventListener('lazybeforeunveil', parentUnveil); | ||
lazySizes.aC(parent, lazySizes.cfg.lazyClass); | ||
} | ||
}; | ||
@@ -193,4 +188,4 @@ | ||
detail.blurUp = match && match[1] || 'always'; | ||
detail.blurUp = match && match[1] || lazySizes.cfg.blurupMode || 'always'; | ||
}); | ||
})); |
@@ -19,3 +19,3 @@ (function(window, factory) { | ||
if(!document.addEventListener){return;} | ||
var config, checkElements, expand; | ||
var config, checkElements; | ||
@@ -28,2 +28,3 @@ var unloadElements = []; | ||
var expand = (lazySizes._defEx + 99) * 1.1; | ||
var vTop = expand * -1; | ||
@@ -148,3 +149,2 @@ var vLeft = vTop; | ||
expand = ((config.expand * config.expFactor) + 99) * 1.1; | ||
checkElements = document.getElementsByClassName([config.unloadClass, config.loadedClass].join(' ')); | ||
@@ -151,0 +151,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
237014
4133