Update Android's ScrollView.scrollTo API to match JS/iOS

Summary:
public
We recently updated the `ScrollResponder.scrollResponderScrollTo` method to accept an `animated` argument, and deprecated the `scrollResponderScrollWithoutAnimationTo` method. This change was reflected in the native iOS implementation, but not on Android.

This diff updates the Android ScrollViewManager implementation to match the JS API, and removes the platform-specific fork in the JS code.

Reviewed By: dmmiller

Differential Revision: D2883515

fb-gh-sync-id: e5a0e1cf470e21af837b2311cf1048162ac3aff5
This commit is contained in:
Nick Lockwood
2016-02-01 04:03:55 -08:00
committed by facebook-github-bot-9
parent 9308f89c1c
commit ee30433b76
5 changed files with 23 additions and 51 deletions

View File

@@ -353,19 +353,11 @@ var ScrollResponderMixin = {
* can also be used to quickly scroll to any element we want to focus
*/
scrollResponderScrollTo: function(offsetX: number, offsetY: number, animated: boolean = true) {
if (Platform.OS === 'android') {
UIManager.dispatchViewManagerCommand(
React.findNodeHandle(this),
UIManager.RCTScrollView.Commands[animated ? 'scrollTo' : 'scrollWithoutAnimationTo'],
[Math.round(offsetX), Math.round(offsetY)],
);
} else {
ScrollViewManager.scrollTo(
React.findNodeHandle(this),
{ x: offsetX, y: offsetY },
animated
);
}
UIManager.dispatchViewManagerCommand(
React.findNodeHandle(this),
UIManager.RCTScrollView.Commands.scrollTo,
[offsetX, offsetY, animated],
);
},
/**