From 4a898522ad3eae38918767634d90347172f3fe9d Mon Sep 17 00:00:00 2001
From: Rafi Zadanly <zadanlyr@gmail.com>
Date: Wed, 15 Mar 2023 15:21:58 +0700
Subject: fix animation mobile

---
 src/pages/_app.jsx | 14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)

(limited to 'src/pages/_app.jsx')

diff --git a/src/pages/_app.jsx b/src/pages/_app.jsx
index e32efc19..8b13cc0b 100644
--- a/src/pages/_app.jsx
+++ b/src/pages/_app.jsx
@@ -4,11 +4,13 @@ import { useRouter } from 'next/router'
 import { AnimatePresence } from 'framer-motion'
 import { Toaster } from 'react-hot-toast'
 import { QueryClient, QueryClientProvider } from 'react-query'
+import useDevice from '@/core/hooks/useDevice'
 
 const queryClient = new QueryClient()
 
 function MyApp({ Component, pageProps }) {
   const router = useRouter()
+  const { isMobile } = useDevice()
 
   return (
     <>
@@ -19,20 +21,14 @@ function MyApp({ Component, pageProps }) {
           className: 'border border-gray_r-8'
         }}
       />
-      <NextProgress
-        color='#F01C21'
-        options={{ showSpinner: false }}
-      />
+      <NextProgress color='#F01C21' options={{ showSpinner: false }} />
       <QueryClientProvider client={queryClient}>
         <AnimatePresence
-          mode='wait'
+          mode={isMobile ? 'wait' : 'sync'}
           initial={false}
           onExitComplete={() => window.scrollTo(0, 0)}
         >
-          <Component
-            {...pageProps}
-            key={router.asPath}
-          />
+          <Component {...pageProps} key={router.asPath} />
         </AnimatePresence>
       </QueryClientProvider>
     </>
-- 
cgit v1.2.3

