antoinelin / react-locomotive-scroll

A locomotive-scroll React wrapper

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

reset scroll in locomotive scroll

FarzinMoha opened this issue · comments

help me please.....
my website have a some Routes and when i change the path the scroll has a problem and doesn't reset scroll size
and it has problem in each page

in LoloScroll component :

import { LocomotiveScrollProvider } from "react-locomotive-scroll";
import "locomotive-scroll/src/locomotive-scroll.scss";
import {useLocation} from 'react-router-dom'

import React, { useRef } from "react";

const LocoScroll = ({children}) => {
const containerRef = useRef(null);
const { pathname } = useLocation()
return (
<LocomotiveScrollProvider
options={{
smooth: true,
}}
watch={ [ ] }
location={pathname}
onLocationChange={scroll => scroll.scrollTo(0, { duration: 0, disableLerp: true })} // If you want to reset the scroll position to 0 for example
containerRef={containerRef}
>


{children}


);
};

export default LocoScroll;

and in App.jsx :

import "./App.scss";
import Main from "./components/Main";
import LocoScroll from "./hooks/LocoScroll";
import { BrowserRouter, Routes, Route } from "react-router-dom";
import AboutMeRoute from "./routes/about-me-route/AboutMeRoute";

const App = () => {
return (

} /> } />
); };

but in Routes not change height of scroll

accually I have problem with react router dom and locomotive scroll