Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

scrollTop is not set when from & to are equal #1185

Closed
kernelwhisperer opened this issue Oct 31, 2020 · 2 comments
Closed

scrollTop is not set when from & to are equal #1185

kernelwhisperer opened this issue Oct 31, 2020 · 2 comments
Assignees
Labels
kind: bug Something isn't working
Projects
Milestone

Comments

@kernelwhisperer
Copy link

from @aleclarson on discord:

You need to provide a start value: from: { scrollTop: 0 }

This fixes it, yes, thanks! 😄 (I guess on v8.0.27 the lib used to do that automatically.)

To achieve my behavior of a initial scrollTop I have to do this now:

  const { scrollTop } = useSpring({
   from: { scrollTop: 0 }
   to: { scrollTop: 100 },
   immediate: true
});

And then to set immediate: false on subsequent calls.

I can live with this... hovever I would still consider this a bug, and expect this expression to work as an equivalent, just like it does in v8.0.27:

  const { scrollTop } = useSpring({
    from: { scrollTop: 100 }
  });

and this should be possible too:

  const { scrollTop } = useSpring({
    from: { scrollTop: 100 }
    to: { scrollTop: 100 }
  });

It works with animated.span so this is most likely an issue in animated.div's scrollTop handling:
https://codesandbox.io/s/react-spring-v9-scrolltop-bug-forked-7h3vf?file=/src/App.js

Originally posted by @0x6431346e in #985 (comment)

@aleclarson aleclarson added kind: bug Something isn't working v9 labels Oct 31, 2020
@aleclarson aleclarson added this to the v9.0.0-rc.4 milestone Oct 31, 2020
@joshuaellis joshuaellis modified the milestones: v9.0.0-rc.4, v9.1.0 Mar 18, 2021
@joshuaellis joshuaellis added this to Todo (is a confirmed bug) in v9.2.0 Mar 18, 2021
@Rohanhacker
Copy link
Contributor

I am working on this one @joshuaellis

Rohanhacker added a commit to Rohanhacker/react-spring that referenced this issue Mar 21, 2021
@joshuaellis joshuaellis moved this from Todo (is a confirmed bug) to In Progress (assign yourself) in v9.2.0 Mar 25, 2021
@joshuaellis
Copy link
Member

resolved by #1354

@joshuaellis joshuaellis moved this from In Progress (assign yourself) to DONE in v9.2.0 Mar 30, 2021
cameron-martin pushed a commit to cameron-martin/react-spring that referenced this issue May 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind: bug Something isn't working
Projects
No open projects
Development

No branches or pull requests

4 participants