, , EvenEmitter Webview . , , .
, , . .
import EventEmitter from 'react-native/Libraries/vendor/emitter/EventEmitter';
this._eventEmitter = new EventEmitter();
this._eventEmitter.addListener('modal', (data) => {
this.setState({
visibleModal: true,
modalData: data
});
});
emitter.emit( "modal", data)
Edit:
, , , .
class Class extends Component {
onStartShouldSetResponder = () => true;
onEvent = (e) => {
let object = {};
object.locationX = e.nativeEvent.locationX;
object.locationY = e.nativeEvent.locationY;
object.pageY = e.nativeEvent.pageY;
object.pageX = e.nativeEvent.pageX;
object.target = e.nativeEvent.target;
object.identifier = e.nativeEvent.identifier;
alert(JSON.stringify(object));
if (object.pageX > this.state.x && object.pageX < (this.state.x + this.state.width) && object.pageY > this.state.y && object.pageY < (this.state.y + this.state.height))
alert("inside")
}
onLayout = (event) => {
this.setState({
x: event.nativeEvent.layout.x,
y: event.nativeEvent.layout.y,
width: event.nativeEvent.layout.width,
height: event.nativeEvent.layout.height,
});
}
render(){
return(
<ScrollView>
<View ref={"target"} style={{
position: 'absolute',
height: 200,
width: 200,
left: 100,
top: 100,
backgroundColor: 'rgba(0,0,0,0.5)'
}}
onLayout={this.onLayout}
/>
<View
onl
onStartShouldSetResponder={this.onStartShouldSetResponder}
onResponderMove={this.onEvent}
style={{
backgroundColor: 'rgba(255,0,0,0.3)',
width: '100%',
height: 150
}}/>
<TouchableWithoutFeedback
onPress={this.onEvent}
onLongPress={this.onEvent}
style={{
backgroundColor: 'rgba(0,255,0,0.3)',
width: '100%',
height: 150
}}>
<View style={{height: 150, backgroundColor: 'rgba(0,255,0,0.3)'}}/>
</TouchableWithoutFeedback>
<View
onTouchStart={this.onEvent}
onTouchEnd={this.onEvent}
style={{
backgroundColor: 'rgba(0,0,255,0.3)',
width: '100%',
height: 150
}}>
</View>
</ScrollView>
);
}
}
,