[FEAT] block reload on scoll
This commit is contained in:
parent
693d59ab68
commit
401e2ce3c5
@ -1,3 +1,5 @@
|
||||
import { useEffect } from 'react';
|
||||
|
||||
import { ErrorBoundary } from '@/errors/ErrorBoundary';
|
||||
|
||||
import { AudioPlayer } from './components';
|
||||
@ -6,6 +8,19 @@ import { AppRoutes } from './scene/AppRoutes';
|
||||
import { ServiceContextProvider } from './service/ServiceContext';
|
||||
|
||||
export const App = () => {
|
||||
// Prevent reload the page when scroll on mobile
|
||||
useEffect(() => {
|
||||
const preventRefresh = (event: { preventDefault: () => void }) => {
|
||||
if (window.scrollY === 0) {
|
||||
event.preventDefault();
|
||||
}
|
||||
};
|
||||
document.addEventListener('touchmove', preventRefresh, { passive: false });
|
||||
return () => {
|
||||
document.removeEventListener('touchmove', preventRefresh);
|
||||
};
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<ServiceContextProvider>
|
||||
<EnvDevelopment />
|
||||
|
Loading…
x
Reference in New Issue
Block a user