My problem is pretty simple, i'm trying to detect the end of a onLongPress event. Basicly when the user release the press.
I'v try every event possible in TouchableWithoutFeedback but there is only one event which is trigger at a time.
import React from 'react'
import {
View,
Text,
Dimensions,
CameraRoll
} from 'react-native'
import Camera from 'react-native-camera';
const { width, height } = Dimensions.get('window')
class ImageBrowser extends React.Component {
static navigationOptions = {
title: 'Unsplash Images',
}
state = {
images: [],
loading: true,
page: 1,
isRecording : false
}
takeVideo(){
this._recordVideo.bind(this);
}
_recordVideo(){
this.camera.capture({mode: Camera.constants.CaptureMode.video})
.then((data) => {
console.log(data);
})
.catch((err) => {
console.log(err)
})
}
_stopRecord(){
this.camera.stopCapture();
}
render() {
return (
<View style={{flex: 1}}>
<Camera
ref={(cam) => {this.camera = cam;}}
style={styles.preview}
aspect={Camera.constants.Aspect.fill}
type={Camera.constants.Type.front}
>
<Text style={styles.capture} onLongPress={this.takeVideo.bind(this)} onPress={this._stopRecord.bind(this)} onPressOut={this._stopRecord.bind(this)}>[CAPTURE]</Text>
</Camera>
</View>
)
}
}
const styles = {
preview: {
flex: 1,
justifyContent: 'flex-end',
alignItems: 'center',
height: Dimensions.get('window').height,
width: Dimensions.get('window').width
},
capture: {
flex: 0,
backgroundColor: '#fff',
borderRadius: 5,
color: '#000',
padding: 10,
margin: 40
}
}
export default ImageBrowser
These long presses can be handled by passing a function to the onLongPress props of any of the "Touchable" components.
TouchableOpacity increases the lighteness of a button when tocuhed while TouchableHighlight increases the darkness of a button when touched.
hitSlop This defines how far your touch can start away from the button. This is added to pressRetentionOffset when moving off of the button.
You can use the View#hitSlop property to increase the touchable area. This can be useful in scenarios where you know that the increased touch area won't overlap with other touchables. A more robust solution is to use the padding style property.
Use Touch*** Component
onPressIn
onPressOut
http://facebook.github.io/react-native/docs/touchablewithoutfeedback.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With