This repository has been archived on 2022-03-12. You can view files and clone it, but cannot push or open issues or pull requests.
Files
reValuate/node_modules/react-native/ReactAndroid/src/androidTest/js/MultitouchHandlingTestAppModule.js
Yamozha 7256d79e2c yeet
2021-04-02 02:24:13 +03:00

79 lines
1.8 KiB
JavaScript

/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
*/
'use strict';
const React = require('react');
const {NativeModules, StyleSheet, View} = require('react-native');
const {Recording} = NativeModules;
const extractSingleTouch = nativeEvent => {
const touches = nativeEvent.touches;
const changedTouches = nativeEvent.changedTouches;
const hasTouches = touches && touches.length > 0;
const hasChangedTouches = changedTouches && changedTouches.length > 0;
return !hasTouches && hasChangedTouches
? changedTouches[0]
: hasTouches
? touches[0]
: nativeEvent;
};
class TouchTestApp extends React.Component {
handleStartShouldSetResponder = e => {
return true;
};
handleOnResponderMove = e => {
e = extractSingleTouch(e.nativeEvent);
Recording.record('move;' + e.touches.length);
};
handleResponderStart = e => {
e = extractSingleTouch(e.nativeEvent);
if (e.touches) {
Recording.record('start;' + e.touches.length);
} else {
Recording.record('start;ExtraPointer');
}
};
handleResponderEnd = e => {
e = extractSingleTouch(e.nativeEvent);
if (e.touches) {
Recording.record('end;' + e.touches.length);
} else {
Recording.record('end;ExtraPointer');
}
};
render() {
return (
<View
style={styles.container}
onStartShouldSetResponder={this.handleStartShouldSetResponder}
onResponderMove={this.handleOnResponderMove}
onResponderStart={this.handleResponderStart}
onResponderEnd={this.handleResponderEnd}
collapsable={false}
/>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
},
});
module.exports = TouchTestApp;