mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-26 13:25:51 +08:00
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:
committed by
facebook-github-bot-9
parent
9308f89c1c
commit
ee30433b76
@@ -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],
|
||||
);
|
||||
},
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user