fixed bug

This commit is contained in:
Vaica committed 2026-01-31 21:27:06 +08:00
1 parent 54b18039e3
commit 8c3232fadf
16 files changed
+1134 -97

No files matched your search

+22 -14
View File
@@ -12,26 +12,34 @@
function init(setting) {
defaults = Object.assign({}, defaults, setting || {});
// Initialize IntersectionObserver
if (!observer) {
observer = new IntersectionObserver(function(entries, self) {
entries.forEach(function(entry) {
if (entry.isIntersecting) {
var img = entry.target;
showImg(img);
self.unobserve(img);
}
});
}, {
rootMargin: defaults.offsetTopm + "px 0px " + defaults.offsetBottom + "px 0px"
});
// Reset observer for PJAX support
if (observer) {
observer.disconnect();
observer = null;
}
// Initialize IntersectionObserver
observer = new IntersectionObserver(function(entries, self) {
entries.forEach(function(entry) {
if (entry.isIntersecting) {
var img = entry.target;
showImg(img);
self.unobserve(img);
}
});
}, {
rootMargin: defaults.offsetTopm + "px 0px " + defaults.offsetBottom + "px 0px"
});
processImages();
}
function processImages() {
var images = document.querySelectorAll('img:not(.blog-img):not([data-comp])');
if (!observer) {
init(); // Auto-initialize if not ready
}
// Expanded selector to catch more images
var images = document.querySelectorAll('img.lazyload, img:not(.blog-img):not([data-comp])');
images.forEach(function(img) {
// Check if already processed or has data-lazy-src
if (img.getAttribute('data-lazy-src')) {