mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Back out "Convert scrollresponder dipatches to native commands"
Summary: Revert D17983169 since it causes instant crash on AMA Changelog: [Internal] Revert D17983169 Differential Revision: D18054783 fbshipit-source-id: 2b0957ee266dc034336eb157a5a343d051563389
This commit is contained in:
committed by
Facebook Github Bot
parent
e6a9f56c04
commit
e515947dfe
@@ -458,21 +458,10 @@ const ScrollResponderMixin = {
|
||||
} else {
|
||||
({x, y, animated} = x || {});
|
||||
}
|
||||
|
||||
const thisRef: React.ElementRef<typeof ScrollView> = (this: any);
|
||||
invariant(
|
||||
thisRef.getNativeScrollRef != null,
|
||||
'Expected scrollTo to be called on a scrollViewRef. If this exception occurs it is likely a bug in React Native',
|
||||
);
|
||||
const nativeScrollRef = thisRef.getNativeScrollRef();
|
||||
if (nativeScrollRef == null) {
|
||||
return;
|
||||
}
|
||||
ScrollView.Commands.scrollTo(
|
||||
nativeScrollRef,
|
||||
x || 0,
|
||||
y || 0,
|
||||
animated !== false,
|
||||
UIManager.dispatchViewManagerCommand(
|
||||
nullthrows(this.scrollResponderGetScrollableNode()),
|
||||
UIManager.getViewManagerConfig('RCTScrollView').Commands.scrollTo,
|
||||
[x || 0, y || 0, animated !== false],
|
||||
);
|
||||
},
|
||||
|
||||
@@ -487,18 +476,11 @@ const ScrollResponderMixin = {
|
||||
scrollResponderScrollToEnd: function(options?: {animated?: boolean}) {
|
||||
// Default to true
|
||||
const animated = (options && options.animated) !== false;
|
||||
|
||||
const thisRef: React.ElementRef<typeof ScrollView> = (this: any);
|
||||
invariant(
|
||||
thisRef.getNativeScrollRef != null,
|
||||
'Expected scrollToEnd to be called on a scrollViewRef. If this exception occurs it is likely a bug in React Native',
|
||||
UIManager.dispatchViewManagerCommand(
|
||||
this.scrollResponderGetScrollableNode(),
|
||||
UIManager.getViewManagerConfig('RCTScrollView').Commands.scrollToEnd,
|
||||
[animated],
|
||||
);
|
||||
const nativeScrollRef = thisRef.getNativeScrollRef();
|
||||
if (nativeScrollRef == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
ScrollView.Commands.scrollToEnd(nativeScrollRef, animated);
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -526,33 +508,27 @@ const ScrollResponderMixin = {
|
||||
'`scrollResponderZoomTo` `animated` argument is deprecated. Use `options.animated` instead',
|
||||
);
|
||||
}
|
||||
|
||||
const thisRef: React.ElementRef<typeof ScrollView> = this;
|
||||
invariant(
|
||||
thisRef.getNativeScrollRef != null,
|
||||
this.getNativeScrollRef != null,
|
||||
'Expected zoomToRect to be called on a scrollViewRef. If this exception occurs it is likely a bug in React Native',
|
||||
);
|
||||
const nativeScrollRef = thisRef.getNativeScrollRef();
|
||||
if (nativeScrollRef == null) {
|
||||
return;
|
||||
}
|
||||
ScrollView.Commands.zoomToRect(nativeScrollRef, rect, animated !== false);
|
||||
ScrollView.Commands.zoomToRect(
|
||||
this.getNativeScrollRef(),
|
||||
rect,
|
||||
animated !== false,
|
||||
);
|
||||
},
|
||||
|
||||
/**
|
||||
* Displays the scroll indicators momentarily.
|
||||
*/
|
||||
scrollResponderFlashScrollIndicators: function() {
|
||||
const thisRef: React.ElementRef<typeof ScrollView> = (this: any);
|
||||
invariant(
|
||||
thisRef.getNativeScrollRef != null,
|
||||
'Expected flashScrollIndicators to be called on a scrollViewRef. If this exception occurs it is likely a bug in React Native',
|
||||
UIManager.dispatchViewManagerCommand(
|
||||
this.scrollResponderGetScrollableNode(),
|
||||
UIManager.getViewManagerConfig('RCTScrollView').Commands
|
||||
.flashScrollIndicators,
|
||||
[],
|
||||
);
|
||||
const nativeScrollRef = thisRef.getNativeScrollRef();
|
||||
if (nativeScrollRef == null) {
|
||||
return;
|
||||
}
|
||||
ScrollView.Commands.flashScrollIndicators(nativeScrollRef);
|
||||
},
|
||||
|
||||
/**
|
||||
|
||||
@@ -585,22 +585,9 @@ export type Props = $ReadOnly<{|
|
||||
children?: React.Node,
|
||||
|}>;
|
||||
|
||||
type ScrollViewNativeComponentType = HostComponent<mixed>;
|
||||
type ScrollViewNativeComponentType = Class<ReactNative.NativeComponent<Props>>;
|
||||
|
||||
interface NativeCommands {
|
||||
+flashScrollIndicators: (
|
||||
viewRef: React.ElementRef<ScrollViewNativeComponentType>,
|
||||
) => void;
|
||||
+scrollTo: (
|
||||
viewRef: React.ElementRef<ScrollViewNativeComponentType>,
|
||||
x: number,
|
||||
y: number,
|
||||
animated: boolean,
|
||||
) => void;
|
||||
+scrollToEnd: (
|
||||
viewRef: React.ElementRef<ScrollViewNativeComponentType>,
|
||||
animated: boolean,
|
||||
) => void;
|
||||
+zoomToRect: (
|
||||
viewRef: React.ElementRef<ScrollViewNativeComponentType>,
|
||||
rect: {|
|
||||
@@ -1243,12 +1230,7 @@ const styles = StyleSheet.create({
|
||||
});
|
||||
|
||||
ScrollView.Commands = codegenNativeCommands<NativeCommands>({
|
||||
supportedCommands: [
|
||||
'flashScrollIndicators',
|
||||
'scrollTo',
|
||||
'scrollToEnd',
|
||||
'zoomToRect',
|
||||
],
|
||||
supportedCommands: ['zoomToRect'],
|
||||
});
|
||||
|
||||
module.exports = ScrollView;
|
||||
|
||||
Reference in New Issue
Block a user