gallery fix
This commit is contained in:
@@ -3,6 +3,34 @@
|
||||
// - mobile menu toggle via [data-mobile-toggle] + #mobileMenu
|
||||
|
||||
(function () {
|
||||
function initBlurPreviewImages() {
|
||||
var selector = 'img[data-blur-preview]';
|
||||
|
||||
function markLoaded(img) {
|
||||
if (!img) return;
|
||||
img.classList.remove('blur-sm', 'scale-[1.02]');
|
||||
img.classList.add('is-loaded');
|
||||
}
|
||||
|
||||
document.querySelectorAll(selector).forEach(function (img) {
|
||||
if (img.complete && img.naturalWidth > 0) {
|
||||
markLoaded(img);
|
||||
return;
|
||||
}
|
||||
img.addEventListener('load', function () { markLoaded(img); }, { once: true });
|
||||
img.addEventListener('error', function () { markLoaded(img); }, { once: true });
|
||||
});
|
||||
|
||||
document.addEventListener('load', function (event) {
|
||||
var target = event.target;
|
||||
if (target && target.matches && target.matches(selector)) {
|
||||
markLoaded(target);
|
||||
}
|
||||
}, true);
|
||||
}
|
||||
|
||||
initBlurPreviewImages();
|
||||
|
||||
function closest(el, selector) {
|
||||
while (el && el.nodeType === 1) {
|
||||
if (el.matches(selector)) return el;
|
||||
|
||||
Reference in New Issue
Block a user