fixed 懒加载效果

This commit is contained in:
Vaica committed 2026-01-31 17:24:31 +08:00
1 parent c26a5ef875
commit 53f2c6076c
3 files changed
+126 -128

No files matched your search

+27 -1
View File
@@ -112,8 +112,34 @@ window.initArtalk = function() {
emoticons: window.artalkConfig.emoticons
});
// Inject AI Comment
// Inject AI Comment & Lazy Load & Animation
window.artalk.on('list-loaded', function() {
// 1. Lazy Load Logic
var artalkImages = document.querySelectorAll('.atk-list-body img');
artalkImages.forEach(function (img) {
var src = img.getAttribute('src');
// Check if it's already lazy loaded or placeholder
if (src && !img.getAttribute('data-lazy-src') && src.indexOf('data:image') !== 0) {
img.setAttribute('data-lazy-src', src);
img.setAttribute('src', 'data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==');
}
});
// 2. Animation Logic
var comments = document.querySelectorAll('.atk-list-body .atk-comment');
if (comments) {
comments.forEach(function (comment, index) {
comment.classList.add('atk-comment-animate');
comment.style.animationDelay = (index * 0.04) + 's';
});
}
// 3. Trigger global lazy load update
if (window.lazyLoadAgain) {
window.lazyLoadAgain();
}
// 4. AI Comment Logic
if (window.artalkConfig.aiComment) {
// Force hide "No comments" message via CSS class
var list = document.querySelector('.atk-list');