fixed 图片懒加载bug
This commit is contained in:
1 parent
819b6d6e85
commit
f8730d09e6
6 files changed
+216
-85
No files matched your search
@@ -348,34 +348,86 @@ function initInlineSearch() {
|
||||
}
|
||||
}
|
||||
|
||||
// Reset text content initially but keep it ready
|
||||
// Pre-fill first character to avoid empty bubble on mobile (where CSS forces visibility)
|
||||
if (text.length > 0) {
|
||||
searchHintText.textContent = text.charAt(0);
|
||||
} else {
|
||||
searchHintText.textContent = '';
|
||||
}
|
||||
|
||||
// Show wrapper initially
|
||||
setTimeout(function() {
|
||||
// Add visible class (triggers fade in on desktop)
|
||||
var typeInterval;
|
||||
var hideTimeout;
|
||||
|
||||
function runTypewriter(str, callback) {
|
||||
if (typeInterval) clearInterval(typeInterval);
|
||||
if (hideTimeout) clearTimeout(hideTimeout);
|
||||
|
||||
// Ensure visible
|
||||
searchHintWrapper.classList.add('visible');
|
||||
|
||||
// Typewriter effect
|
||||
var i = 1;
|
||||
var typeInterval = setInterval(function() {
|
||||
if (i >= text.length) {
|
||||
// Pre-fill first char
|
||||
if (str.length > 0) {
|
||||
searchHintText.textContent = str.charAt(0);
|
||||
}
|
||||
|
||||
typeInterval = setInterval(function() {
|
||||
if (i >= str.length) {
|
||||
clearInterval(typeInterval);
|
||||
|
||||
// Hide after 8 seconds (give more time to read greetings)
|
||||
setTimeout(function() {
|
||||
searchHintWrapper.classList.remove('visible');
|
||||
}, 8000);
|
||||
if (callback) callback();
|
||||
return;
|
||||
}
|
||||
searchHintText.textContent = text.substring(0, i + 1);
|
||||
searchHintText.textContent = str.substring(0, i + 1);
|
||||
i++;
|
||||
}, 100);
|
||||
}, 500);
|
||||
}
|
||||
|
||||
// Check session storage for Jiaotailang tip
|
||||
if (!sessionStorage.getItem('jiaotailang_shown')) {
|
||||
// Initial Delay
|
||||
setTimeout(function() {
|
||||
// Step 1: Show Greeting
|
||||
runTypewriter(text, function() {
|
||||
// Animation Finished
|
||||
|
||||
// Step 2: Check Mobile Logic
|
||||
if (window.isMobile && window.isMobile()) {
|
||||
// Wait 2s then show secret hint
|
||||
hideTimeout = setTimeout(function() {
|
||||
var secretHint = "悄悄咪咪告诉你 点击随笔开始搜索";
|
||||
runTypewriter(secretHint, function() {
|
||||
// Finished secret hint
|
||||
sessionStorage.setItem('jiaotailang_shown', 'true');
|
||||
// Hide after 5s
|
||||
hideTimeout = setTimeout(function() {
|
||||
searchHintWrapper.classList.remove('visible');
|
||||
}, 5000);
|
||||
});
|
||||
}, 2000);
|
||||
} else {
|
||||
// Desktop: Just hide after 8s
|
||||
sessionStorage.setItem('jiaotailang_shown', 'true');
|
||||
hideTimeout = setTimeout(function() {
|
||||
searchHintWrapper.classList.remove('visible');
|
||||
}, 8000);
|
||||
}
|
||||
});
|
||||
}, 500);
|
||||
} else {
|
||||
// If already shown, set full text but don't auto-show
|
||||
searchHintText.textContent = text;
|
||||
}
|
||||
|
||||
// --- Hover Logic (Desktop) ---
|
||||
if (!window.isMobile || !window.isMobile()) {
|
||||
header.addEventListener('mouseenter', function() {
|
||||
// Stop any running animations
|
||||
if (typeInterval) clearInterval(typeInterval);
|
||||
if (hideTimeout) clearTimeout(hideTimeout);
|
||||
|
||||
searchHintWrapper.classList.add('visible');
|
||||
searchHintText.textContent = "点击随笔,开始搜索";
|
||||
});
|
||||
|
||||
header.addEventListener('mouseleave', function() {
|
||||
// Simply hide when leaving
|
||||
searchHintWrapper.classList.remove('visible');
|
||||
// Optional: Reset text to greeting in case it's shown again by some other logic?
|
||||
// But mostly it will be triggered by hover again.
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user