0
我正在嘗試做一個拖放組件,並且爲此需要使用dropZone的x和y位置。一切都很好,但是當我嘗試獲取區域和我的dropzone的位置時在視圖內react-native給我一個基於視圖的值,我可以以某種方式知道根位置。如何用event.nativeEvent.layout計算位置在視圖中時的位置
絲毫onLayout我把事件
<View style={styles.borderView}>
<Text style={styles.text}>
after he had dug down only a few inches he uncovered a
<View
onLayout={this.setDropZoneValues.bind(this)}
style={styles.viewDropZone}
>
<Text>_________</Text>
</View>
of silver coins and jewelry. He couldn’t believe it
</Text>
</View>
下面我帶的面積,Y和X
setDropZoneValues(event) {
this.props.setDropZoneValue(event.nativeEvent.layout);
}
風格
viewDropZone: {
backgroundColor:'red',
height: 10,
width: 60
},
text: {
backgroundColor: theme.colors.transparent,
textAlign: 'left',
},
borderView: {
backgroundColor: theme.colors.colomboGrayBackground,
marginTop: 5,
margin: 8,
padding: 10,
borderStyle: 'dashed',
borderWidth: 1.5,
borderRadius: 2,
borderColor: theme.colors.colomboSubTitle,
},
感謝