mirror of
https://github.com/timmypidashev/web.git
synced 2026-04-14 02:53:51 +00:00
mobile optimizations
This commit is contained in:
@@ -13,9 +13,7 @@ export default function Intro() {
|
|||||||
const inView = rect.top < window.innerHeight && rect.bottom > 0;
|
const inView = rect.top < window.innerHeight && rect.bottom > 0;
|
||||||
const isReload = performance.getEntriesByType?.("navigation")?.[0]?.type === "reload";
|
const isReload = performance.getEntriesByType?.("navigation")?.[0]?.type === "reload";
|
||||||
const isSpaNav = !!(window as any).__astroNavigation;
|
const isSpaNav = !!(window as any).__astroNavigation;
|
||||||
const mobile = window.innerWidth < 1024;
|
if (inView && (isReload || isSpaNav)) {
|
||||||
|
|
||||||
if (inView && (mobile || isReload || isSpaNav)) {
|
|
||||||
setVisible(true);
|
setVisible(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,9 +29,7 @@ const Stats = () => {
|
|||||||
const inView = rect.top < window.innerHeight && rect.bottom > 0;
|
const inView = rect.top < window.innerHeight && rect.bottom > 0;
|
||||||
const isReload = performance.getEntriesByType?.("navigation")?.[0]?.type === "reload";
|
const isReload = performance.getEntriesByType?.("navigation")?.[0]?.type === "reload";
|
||||||
const isSpaNav = !!(window as any).__astroNavigation;
|
const isSpaNav = !!(window as any).__astroNavigation;
|
||||||
const mobile = window.innerWidth < 1024;
|
if (inView && (isReload || isSpaNav)) {
|
||||||
|
|
||||||
if (inView && (mobile || isReload || isSpaNav)) {
|
|
||||||
setSkipAnim(true);
|
setSkipAnim(true);
|
||||||
setIsVisible(true);
|
setIsVisible(true);
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -36,9 +36,7 @@ const DetailedStats = () => {
|
|||||||
const inView = rect.top < window.innerHeight && rect.bottom > 0;
|
const inView = rect.top < window.innerHeight && rect.bottom > 0;
|
||||||
const isReload = performance.getEntriesByType?.("navigation")?.[0]?.type === "reload";
|
const isReload = performance.getEntriesByType?.("navigation")?.[0]?.type === "reload";
|
||||||
const isSpaNav = !!(window as any).__astroNavigation;
|
const isSpaNav = !!(window as any).__astroNavigation;
|
||||||
const mobile = window.innerWidth < 1024;
|
if (inView && (isReload || isSpaNav)) {
|
||||||
|
|
||||||
if (inView && (mobile || isReload || isSpaNav)) {
|
|
||||||
setSkipAnim(true);
|
setSkipAnim(true);
|
||||||
setVisible(true);
|
setVisible(true);
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -53,9 +53,7 @@ function TimelineCard({ item, index }: { item: (typeof timelineItems)[number]; i
|
|||||||
const isReload = performance.getEntriesByType?.("navigation")?.[0]?.type === "reload";
|
const isReload = performance.getEntriesByType?.("navigation")?.[0]?.type === "reload";
|
||||||
const isSpaNav = !!(window as any).__astroNavigation;
|
const isSpaNav = !!(window as any).__astroNavigation;
|
||||||
|
|
||||||
const mobile = window.innerWidth < 1024;
|
if (inView && (isReload || isSpaNav)) {
|
||||||
|
|
||||||
if (inView && (mobile || isReload || isSpaNav)) {
|
|
||||||
setSkip(true);
|
setSkip(true);
|
||||||
setVisible(true);
|
setVisible(true);
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -1,11 +1,6 @@
|
|||||||
import { useEffect, useRef, useState } from "react";
|
import { useEffect, useRef, useState } from "react";
|
||||||
import { prefersReducedMotion } from "@/lib/reduced-motion";
|
import { prefersReducedMotion } from "@/lib/reduced-motion";
|
||||||
|
|
||||||
function isMobile(): boolean {
|
|
||||||
if (typeof window === "undefined") return false;
|
|
||||||
return window.innerWidth < 1024;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface AnimateInProps {
|
interface AnimateInProps {
|
||||||
children: React.ReactNode;
|
children: React.ReactNode;
|
||||||
delay?: number;
|
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 isReload = (performance.getEntriesByType?.("navigation")?.[0] as PerformanceNavigationTiming)?.type === "reload";
|
||||||
const isSpaNav = !!(window as any).__astroNavigation;
|
const isSpaNav = !!(window as any).__astroNavigation;
|
||||||
|
|
||||||
// On mobile: skip animation for anything already in view (prevents flicker on navigation)
|
if (inView && (isReload || isSpaNav)) {
|
||||||
// On desktop: only skip on reload or SPA nav
|
|
||||||
if (inView && (isMobile() || isReload || isSpaNav)) {
|
|
||||||
setSkip(true);
|
setSkip(true);
|
||||||
setVisible(true);
|
setVisible(true);
|
||||||
return;
|
return;
|
||||||
|
|||||||
Reference in New Issue
Block a user