Files
react-native/packages/rn-tester/js/examples/Experimental/Compatibility/CompatibilityNativeGestureHandling.js
T
Luna Wei 5198d56f28 Stop sending PointerEvents when view is native gesture handling
Summary:
Changelog: [Internal] - Stop dispatching pointer events when a child view has indicated it wants to handle a native gesture.

In discussion and alignment with web standards, we've decided to not dispatch any pointer events during a native gesture.

Currently, on ACTION_HOVER_MOVE, we remove child views of the native gesture handling view and continue dispatching onPointerMove for ancestor views. This change removes this logic and won't dispatch a onPointerMove event at all.

For all other MotionEvent actions, this is already the case.

Also adding an example in RNTester that involves a scrollView (which handles gestures during scrolling)

Reviewed By: javache

Differential Revision: D39377157

fbshipit-source-id: cb0a719f67136e31b68d6f6e794fee10b256bf21
2022-09-12 12:17:21 -07:00

65 lines
1.6 KiB
JavaScript

/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
* @flow
*/
import * as React from 'react';
import {ScrollView, View, StyleSheet} from 'react-native';
import EventfulView from '../W3CPointerEventsEventfulView';
import type {RNTesterModuleExample} from '../../../types/RNTesterTypes';
const styles = StyleSheet.create({
container: {
borderWidth: 1,
},
eventfulView: {
borderWidth: 1,
height: 100,
width: '100%',
},
lighblue: {
backgroundColor: 'lightblue',
},
item: {
height: 40,
},
});
function CompatibilityNativeGestureHandling(): React.Node {
return (
<View style={styles.container}>
<ScrollView>
{Array(100)
.fill()
.map((_, index) => {
return (
<EventfulView
log={console.log}
onDown
onCancel
key={index}
name={`${index}`}
style={[styles.item, index % 2 === 0 ? styles.lighblue : null]}
/>
);
})}
</ScrollView>
</View>
);
}
export default ({
name: 'compatibility_native_gesture',
title: 'Native Gesture Handling Example',
description:
'Scroll to trigger a native gesture. Verify no native events are being fired once a native gesture starts until it ends. A pointer cancel will be triggered when a native gesture starts.',
render(): React.Node {
return <CompatibilityNativeGestureHandling />;
},
}: RNTesterModuleExample);