mirror of
https://github.com/timmypidashev/web.git
synced 2026-04-14 11:03:50 +00:00
mobile optimizations
This commit is contained in:
@@ -1,11 +1,6 @@
|
||||
import { useEffect, useRef, useState } from "react";
|
||||
import { prefersReducedMotion } from "@/lib/reduced-motion";
|
||||
|
||||
function isMobile(): boolean {
|
||||
if (typeof window === "undefined") return false;
|
||||
return window.innerWidth < 1024;
|
||||
}
|
||||
|
||||
interface AnimateInProps {
|
||||
children: React.ReactNode;
|
||||
delay?: number;
|
||||
@@ -32,9 +27,7 @@ export function AnimateIn({ children, delay = 0, threshold = 0.15 }: AnimateInPr
|
||||
const isReload = (performance.getEntriesByType?.("navigation")?.[0] as PerformanceNavigationTiming)?.type === "reload";
|
||||
const isSpaNav = !!(window as any).__astroNavigation;
|
||||
|
||||
// On mobile: skip animation for anything already in view (prevents flicker on navigation)
|
||||
// On desktop: only skip on reload or SPA nav
|
||||
if (inView && (isMobile() || isReload || isSpaNav)) {
|
||||
if (inView && (isReload || isSpaNav)) {
|
||||
setSkip(true);
|
||||
setVisible(true);
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user