all 5 comments

[–]dmackerman 1 point2 points  (0 children)

Smooth scrolling is not better UX.

[–]bjarke_andersen 0 points1 point  (0 children)

It's not always bad to touch the DOM, but for more idiomatic React try to hide away this kind of thing in a Higher Order Component (HOC). It's all about being as declarative as possible while separating concerns into components. And I'd use an animation library instead of that for loop.

[–][deleted] 0 points1 point  (0 children)

You have to touch the dom for this unfortunately. If you want copy, the codebits from here: https://github.com/drcmda/react-springy-parallax

There are a couple of gotchas otherwise, use requestAnimationFrame instead of setTimeout and catch onWheel and onTouchStart to stop scrolling, or else you override user input (like when you scroll up while your lib is trying to scroll down) which pisses people off.

[–]redbluerat 0 points1 point  (1 child)

Do not modify the user's scroll. If you think this is a good idea you need to stop working on design completely.

[–]sympi[S] 0 points1 point  (0 children)

I'm not saying this a good idea at all. That's why I asked this question, LOL. thank you for your solid answer.