handling cloud page transitions

This commit is contained in:
Antoine M 2024-02-22 19:15:42 +01:00
parent b47bddba81
commit 2b651e3f60
2 changed files with 52 additions and 13 deletions

View File

@ -9,26 +9,52 @@ import Test from "./pages/Test.jsx";
import { v4 as uuidv4 } from "uuid"; import { v4 as uuidv4 } from "uuid";
import Game from "./pages/Game.jsx"; import Game from "./pages/Game.jsx";
import Rating from "./pages/Rating.jsx"; import Rating from "./pages/Rating.jsx";
import Lottie from "lottie-react";
import { useLocation, Routes, Route } from "react-router-dom"; import { useLocation, Routes, Route } from "react-router-dom";
import { AnimatePresence } from "framer-motion"; import { AnimatePresence } from "framer-motion";
import cloudPageTransition from "./assets/animations/transition-nuages-pages";
import React, { useEffect, useRef } from "react";
function App() { function App() {
const location = useLocation(); const location = useLocation();
return (
<AnimatePresence mode='wait'>
<Routes location={location} key={location.pathname}> const playerRef = useRef(Lottie);
<Route path='/' element={<Welcome />} />
<Route path='/home' element={<Home />} /> const playAnimation = () => {
<Route path='/select-profile' element={<Profile />} /> playerRef.current.goToAndPlay(0);
<Route path='/select-country' element={<Country />} /> };
<Route path='/play' element={<Game />} />
<Route path='/results' element={<Results />} /> useEffect(() => {
<Route path='/rating' element={<Rating />} /> playAnimation();
<Route path='/test' element={<Test />} /> }, [location]);
</Routes>
</AnimatePresence> return (
<>
{/* <button onClick={playAnimation}>qsdqsd</button> */}
<Lottie
lottieRef={playerRef}
className='test-load-animation'
animationData={cloudPageTransition}
speed={21}
// loop={false}
loop={false}
autoplay
/>
<AnimatePresence mode='wait'>
<Routes location={location} key={location.pathname}>
<Route path='/' element={<Welcome />} />
<Route path='/home' element={<Home />} />
<Route path='/select-profile' element={<Profile />} />
<Route path='/select-country' element={<Country />} />
<Route path='/play' element={<Game />} />
<Route path='/results' element={<Results />} />
<Route path='/rating' element={<Rating />} />
<Route path='/test' element={<Test />} />
</Routes>
</AnimatePresence>
</>
); );
} }

View File

@ -31,3 +31,16 @@
p { p {
@apply my-0; @apply my-0;
} }
.test-load-animation {
@apply w-full h-full fixed top-0 left-0;
z-index: 90;
position: fixed;
z-index: 40;
pointer-events: none;
svg {
// @apply bg-green-400;
width: 100px;
heigth: 100px;
}
}