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:
James Ide
2015-09-23 05:57:00 -07:00
committed by facebook-github-bot-7
parent 5b0dd6432a
commit 3b68869fc8
5 changed files with 52 additions and 5 deletions

View File

@@ -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}