fixed 样式错误

This commit is contained in:
Vaica committed 2026-02-01 17:42:15 +08:00
1 parent 62e547b2ee
commit 6f5fe6de35
5 files changed
+133 -28

No files matched your search

+41
View File
@@ -28,4 +28,45 @@ document.addEventListener('DOMContentLoaded', function() {
if (window.initCodeCopy) window.initCodeCopy();
if (window.initParagraphComments) window.initParagraphComments();
if (window.initInfiniteScroll && window.enableInfiniteScroll) window.initInfiniteScroll();
// Initialize Typewriter Effect for Mobile Header
initTypewriter();
});
/**
* Typewriter Effect for Mobile Header Bio
*/
function initTypewriter() {
// Only run on mobile or if the element is visible
const bioElement = document.querySelector('.header-bio');
if (!bioElement) return;
// Check if we are on mobile (matching CSS media query)
const isMobile = window.matchMedia('(max-width: 768px)').matches;
if (!isMobile) return;
const originalText = bioElement.innerText.trim();
if (!originalText) return;
// Clear text initially
bioElement.innerText = '';
bioElement.classList.add('typing');
let i = 0;
const speed = 100; // Typing speed in ms
function typeWriter() {
if (i < originalText.length) {
bioElement.innerText += originalText.charAt(i);
i++;
setTimeout(typeWriter, speed);
} else {
// Typing finished, remove cursor after a delay?
// bioElement.classList.remove('typing');
// Keep blinking cursor for effect
}
}
// Start typing with a small delay
setTimeout(typeWriter, 500);
}