fisshy / react-scroll

React scroll component
https://github.com/fisshy/react-scroll/blob/master/README.md
MIT License
4.36k stars 437 forks source link

'smooth: true' causes scrollTo to not work in Chrome, Edge, but works on Firefox #490

Open rjworks opened 2 years ago

rjworks commented 2 years ago
scroller.scrollTo(scrollRef.current[nextPage].props.name, {
                    duration: 800,
                    delay: 0,
                    smooth: true
                });

doesn't work in chrome and edge. works on firefox though.

When I remove smooth: true, it works on every browser. but it's ugly

Deadpool957 commented 2 years ago

I have the same problem,when I use smooth,Cannot roll to specified position

fisshy commented 2 years ago

Could you provide a plunkr/codepen to demonstrate the issue?

Deadpool957 commented 2 years ago

it can not work

Deadpool957 commented 2 years ago

Roll inside the container,The height of the container is fixed, and the page will scroll automatically after loading

Deadpool957 commented 2 years ago

you can see this,https://codesandbox.io/s/container-forked-c3kse?file=/src/index.js

fisshy commented 2 years ago

@rjworks Would it work if you wrote it like this instead.

scroller.scrollTo("scroll-to-element", {
      duration: 800,
      delay: 0,
      smooth: "easeInOutQuart",
      offset: offset
    });
Calisto184AC0 commented 2 years ago

I had the same problem. But in my case I had a CSS property like this: html { scroll-behavior: smooth } When I removed this line it worked correctly.

saschadiercks commented 2 years ago

Yes, it seems react-scroll doesn't work as expected when the scroll-behavior is set in the CSS. Since it is not always an option, to remove the scroll-behavior from the CSS (because it is quite handy) - is there a way to work around this using react-scroll?

danny-dang commented 1 year ago

For me, scroll-behavior: smooth also caused the issue.

Maybe it's better to have this documented.

sbuys commented 6 months ago

For me, scroll-behavior: smooth also caused the issue.

Maybe it's better to have this documented.

Yes please update the documentation with this. Would have saved team many hours.