Вот мой код прикреплен
Код: Выделить всё
const isHomePage =
window.location.pathname === "/" || window.location.pathname === "/index.html" || window.location.pathname.endsWith("/index.html") || window.location.pathname.includes("Portfolio");
// Check if this is a page refresh
const lastLoadTime = localStorage.getItem("lastLoadTime");
const currentTime = new Date().getTime();
const isRefresh = lastLoadTime && currentTime - lastLoadTime < 3000;
// Within 3 seconds considered a refresh
console.log(isRefresh);
// Update last load time
localStorage.setItem("lastLoadTime", currentTime);
const shouldPlayAnimation = isHomePage && (!localStorage.getItem("hasVisited") || isRefresh);
const shouldPlayAnimation = isHomePage && !localStorage.getItem("hasVisited");
console.log(shouldPlayAnimation);
// Only run animations if we're on home page AND animation hasn't played yet
if (shouldPlayAnimation) {
document.body.classList.add("initial-load");
}
Подробнее здесь: https://stackoverflow.com/questions/793 ... -portfolio
Мобильная версия