-
Notifications
You must be signed in to change notification settings - Fork 24.4k
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
Add ability to control scroll animation duration for Android #22884
Conversation
Generated by 🚫 dangerJS |
Ping @hramos |
@osdnk thanks for picking up the work! I think the only remaining piece of feedback left to apply would be @janicduplessis's Apr 24, 2018 comment:
What do you think? |
I thought it will be a bit easier. I need to dig into this PR deeped |
Thanks! I simplified it a little bit following my intuition and your advices! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code looks good! Just one small thing to make it clearer.
...tAndroid/src/main/java/com/facebook/react/views/scroll/ReactHorizontalScrollViewManager.java
Show resolved
Hide resolved
Here you are @janicduplessis |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Many people have reviewed this PR and it's previous version over the last year and the authors have done everything that we asked for. I am assuming this is safe to land now so I'm going ahead and ship this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cpojer is landing this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
Sorry for the churn, but seems like this broke some internal callsites, so we'll have to revert it for now. We'll figure out how to address it and update this thread again -- @cpojer |
…k#22884) Summary: Motivation: ---------- This is one of the more sought after feature requests for RN: react-native.canny.io/feature-requests/p/add-speed-attribute-to-scrollto This PR adds the support to add a "duration" whenever using "scrollTo" or "scrollToEnd" with a scrollView. Currently this only exists for Android as the iOS implementation will be somewhat more involved. This PR is also backwards compatible and does not yet deprecate the "animated" boolean. It may not make sense to ever deprecate "animated", as it could be the flag that is used when devs want the system default duration (which is 250ms for Android). I'm not sure what it is for iOS. It would simplify things to remove "animated", though. Pull Request resolved: facebook#22884 Differential Revision: D13860038 Pulled By: cpojer fbshipit-source-id: f06751d063a33d7046241c95348b6abbb327d36f
Damn, I was so excited for this :( Seems the docs still mention it. I was trying to use it and scratching my head why it doesn't work. |
Motivation:
This is one of the more sought after feature requests for RN:
react-native.canny.io/feature-requests/p/add-speed-attribute-to-scrollto
This PR adds the support to add a "duration" whenever using "scrollTo" or "scrollToEnd" with
a scrollView. Currently this only exists for Android as the iOS implementation will be somewhat more involved.
This PR is also backwards compatible and does not yet deprecate the "animated" boolean. It may not make sense to ever deprecate "animated", as it could be the flag that is used when devs want the system default duration (which is 250ms for Android). I'm not sure what it is for iOS. It would simplify things to remove "animated", though.
Test Plan:
Create a ScollView component that overflows the bounds of the container, e.g.:
Using the "scrollView" ref and the Button callback, scroll to a position with a desired duration speed, e.g:
Ensure the legacy "animated" boolean works as expected:
Test that you can animate the x position as well (change the ScrollView to be horizontal).
Test that the scroll animation is canceled when touching on the scroll view in the middle of an animation.
Test that repeated calls to animate the scrollView don't queue up (e.g. smashing the in the example above, and then tapping into the scrollView should cancel any animation movement).
Vertical scroll:
drive.google.com/file/d/1VhaolHx63GOv0YWTg7ay0GtzW1nIk635/view?usp=sharing
Horizontal scroll:
drive.google.com/file/d/1yq5P1k4-KPPu9BhS6B9liL-NRGX1Z4gA/view?usp=sharing
Related PRs:
Abandoned PR to bring "duration" to iOS:
#1334
Updated docs on react-native-website:
facebook/react-native-website#115
Changelog:
[Android] [Enhancement] - Added support for controlling animation duration speed for methods "scrollTo" and "scrollToEnd"
This is a copy of #17422 with resolved conflicts and style fixes.