mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-28 20:25:33 +08:00
Add scrollWithoutAnimationTo to Android
Summary: `ScrollView.scrollWithoutAnimationTo` is supported on iOS but not Android. This is an existing API, and this diff adds Android support. Closes https://github.com/facebook/react-native/pull/2695 Reviewed By: @svcscm Differential Revision: D2452630 Pulled By: @mkonicek
This commit is contained in:
committed by
facebook-github-bot-7
parent
5b0dd6432a
commit
3b68869fc8
@@ -366,6 +366,26 @@ var ScrollResponderMixin = {
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Like `scrollResponderScrollTo` but immediately scrolls to the given
|
||||
* position
|
||||
*/
|
||||
scrollResponderScrollWithouthAnimationTo: function(offsetX: number, offsetY: number) {
|
||||
if (Platform.OS === 'android') {
|
||||
RCTUIManager.dispatchViewManagerCommand(
|
||||
React.findNodeHandle(this),
|
||||
RCTUIManager.RCTScrollView.Commands.scrollWithoutAnimationTo,
|
||||
[offsetX, offsetY],
|
||||
);
|
||||
} else {
|
||||
RCTUIManager.scrollWithoutAnimationTo(
|
||||
React.findNodeHandle(this),
|
||||
offsetX,
|
||||
offsetY
|
||||
);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* A helper function to zoom to a specific rect in the scrollview.
|
||||
* @param {object} rect Should have shape {x, y, width, height}
|
||||
|
||||
Reference in New Issue
Block a user