-
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 #17422
Changes from all commits
64e5e7c
e27720b
3df7093
f153d4f
25b5ec6
5399cb4
4bf0dce
7d37961
2896cf1
8dcc2e9
cd49a31
2f54dfc
6161dd8
1eb2cf6
26bc7bc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,9 @@ | |
|
||
package com.facebook.react.views.scroll; | ||
|
||
import android.animation.ObjectAnimator; | ||
import android.animation.PropertyValuesHolder; | ||
|
||
import android.view.View; | ||
import android.view.ViewGroup; | ||
|
||
|
@@ -94,4 +97,18 @@ public static int parseOverScrollMode(String jsOverScrollMode) { | |
throw new JSApplicationIllegalArgumentException("wrong overScrollMode: " + jsOverScrollMode); | ||
} | ||
} | ||
|
||
/** | ||
* Helper method for animating to a ScrollView position with a given duration, | ||
* instead of using "smoothScrollTo", which does not expose a duration argument. | ||
*/ | ||
public static ObjectAnimator animateScroll(final ViewGroup scrollView, int mDestX, int mDestY, int mDuration) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have no idea if this Animator object is legit - @janicduplessis or @mdvacca? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It has support from API 11: https://developer.android.com/reference/android/animation/ObjectAnimator.html FWIW we've been using this ScrollView (via overwriting the ScrollView package in MainApplication.Java) in production for the past 6 weeks, in production / release. We also use it in a fairly expensive SectionList which does all sorts of crazy optimizations and is a good stress test for performance. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would still like signoff from someone that knows our android codebase...@janicduplessis, @mdvacca, or @axe-fb? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sounds good. |
||
PropertyValuesHolder scrollX = PropertyValuesHolder.ofInt("scrollX", mDestX); | ||
PropertyValuesHolder scrollY = PropertyValuesHolder.ofInt("scrollY", mDestY); | ||
|
||
final ObjectAnimator animator = ObjectAnimator.ofPropertyValuesHolder(scrollView, scrollX, scrollY); | ||
|
||
animator.setDuration(mDuration).start(); | ||
return animator; | ||
} | ||
} |
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.
Can you open a PR that applies these same changes to https://github.com/facebook/react-native-website/blob/master/docs/scrollview.md ?
These comments are not synced. At some point we need to update these comments with links to the generated docs at http://facebook.github.io/react-native instead (I've done this with a few source files already but had not gotten to ScrollView yet).
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.
Done:
facebook/react-native-website#115