locomotive-scroll icon indicating copy to clipboard operation
locomotive-scroll copied to clipboard

Showing 2 Vertical Scroll bar

Open imprathamesh opened this issue 2 years ago • 11 comments

Hello, after starting the locomotive the page showing 2 vertical scroll bar. and If I redirect another page then on that page show 3 scroll bar.

imprathamesh avatar Sep 03 '22 09:09 imprathamesh

@imprathamesh That is because you are initiating Loco motive multiple times, A locomotive scroll bar represents an instance of locomotive, Where do you initialize it? Are you using react 18? Provide more information so we can help you.

obinasBaba avatar Sep 04 '22 10:09 obinasBaba

Hello, after starting the locomotive the page showing 2 vertical scroll bar. and If I redirect another page then on that page show 3 scroll bar.

you can use locoScroll.destroy();

and then init before page load

locoScroll.init();
locoScroll.start();
locoScroll.update();

heyadeivan avatar Sep 05 '22 01:09 heyadeivan

@imprathamesh That is because you are initiating Loco motive multiple times, A locomotive scroll bar represents an instance of locomotive, Where do you initialize it? Are you using react 18? Provide more information so we can help you.

I m using Blazor WASM which is SPA. here is my code.- I added code in site.js file and import it into index.html

site.js `function callLocomotive() { const scroll = new LocomotiveScroll({ el: document.querySelector('[data-scroll-container]'), smooth: true

});
scroll.Init();

}`

imprathamesh avatar Sep 06 '22 08:09 imprathamesh

Hello, after starting the locomotive the page showing 2 vertical scroll bar. and If I redirect another page then on that page show 3 scroll bar.

you can use locoScroll.destroy();

and then init before page load

locoScroll.init();
locoScroll.start();
locoScroll.update();

Ok. I will let you know

imprathamesh avatar Sep 06 '22 08:09 imprathamesh

Hello, after starting the locomotive the page showing 2 vertical scroll bar. and If I redirect another page then on that page show 3 scroll bar.

you can use locoScroll.destroy();

and then init before page load

locoScroll.init();
locoScroll.start();
locoScroll.update();

I tried as you said but it is not working. Is there any solution for blazor WASM.

imprathamesh avatar Sep 07 '22 05:09 imprathamesh

Hi everyone, I'm also having the same problem. Two scrollbars in a Nextjs application, however I'm using the "react-locomotive-scroll" lib and I have only 1 provider, it's pretty confusing...

Print https://prnt.sc/q9kC7xjd8V8N

flavio-ever avatar Sep 18 '22 20:09 flavio-ever

To fix the issue, you may remove the react.strictmode from the index.js to prevent double render

Andy0926 avatar Oct 28 '22 08:10 Andy0926

Had the same issue and removing strict mode resolved the issue for me.

BryantHustles avatar Nov 01 '22 04:11 BryantHustles

To fix the issue, you may remove the react.strictmode from the index.js to prevent double render

yes this works.

Vijay1667 avatar Feb 19 '23 17:02 Vijay1667

要解决这个问题,你可以从索引.js中删除react.strictmode,以防止双重渲染

This is a good method, how should vue handle this too difficult

chitandaer avatar Dec 07 '23 01:12 chitandaer

Adding on here that this also fixed the issue for me. More directly, in Nextjs 13 at least (likely works with Page router as well), you can add the following to your next.config.js:

const nextConfig = {
  // Removing strict mode is required in order to get locomotive scroll working
  // properly in our Next.js app. This is a known issue with locomotive-scroll
  // and Next.js. https://github.com/locomotivemtl/locomotive-scroll/issues/458
  reactStrictMode: false,
  ...
};

bradley avatar Feb 23 '24 01:02 bradley