[FEAT] block reload on scoll

This commit is contained in:
Edouard DUPIN 2025-03-22 12:12:08 +01:00
parent 693d59ab68
commit 401e2ce3c5

View File

@ -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 />