diff --git a/app/Canvas.tsx b/app/Canvas.tsx index e4b6e5387..91caa7a86 100644 --- a/app/Canvas.tsx +++ b/app/Canvas.tsx @@ -164,7 +164,6 @@ function SubscribeToFrameloop() { type CanvasApi = { isPaused: boolean isLoaded: boolean - isLazyLoaded: boolean pause: () => void play: () => void onPauseCallbacks: (() => void)[] @@ -172,13 +171,11 @@ type CanvasApi = { onPause: (callback: () => void) => () => void onPlay: (callback: () => void) => () => void setIsLoaded: (isLoaded: boolean) => void - setIsLazyLoaded: (isLazyLoaded: boolean) => void } export const useCanvasApi = create((set, get) => ({ isPaused: true, isLoaded: false, - isLazyLoaded: typeof window === 'undefined' ? false : window.location.pathname !== '/', onPauseCallbacks: [], onPlayCallbacks: [], onPause: (callback) => { @@ -206,5 +203,4 @@ export const useCanvasApi = create((set, get) => ({ onPlay.forEach((fn) => fn()) }, setIsLoaded: (isLoaded) => set({ isLoaded }), - setIsLazyLoaded: (isLazyLoaded) => set({ isLazyLoaded }), })) diff --git a/components/Spinner.tsx b/components/Spinner.tsx index 1350ee568..86bc55033 100644 --- a/components/Spinner.tsx +++ b/components/Spinner.tsx @@ -1,11 +1,14 @@ 'use client' import { useSpring, a } from '@react-spring/web' import { useCanvasApi } from 'app/Canvas' +import { usePathname } from 'next/navigation' import { useEffect } from 'react' export function Spinner() { const isLoaded = useCanvasApi((state) => state.isLoaded) - const isLazyLoaded = useCanvasApi((state) => state.isLazyLoaded) + const pathname = usePathname() + + const isLazyLoaded = pathname !== '/' const [props, springApi] = useSpring(() => ({ opacity: isLazyLoaded ? 0 : 1 }))