@@ -46,6 +46,14 @@ const _styles = {
4646 backgroundColor : '#eee' ,
4747 borderColor : 'black' ,
4848 } ) ,
49+ testContainer4 : RX . Styles . createViewStyle ( {
50+ flex : 1 ,
51+ height : 150 ,
52+ margin : 20 ,
53+ borderWidth : 1 ,
54+ backgroundColor : '#eee' ,
55+ borderColor : 'black' ,
56+ } ) ,
4957 success : RX . Styles . createViewStyle ( {
5058 borderWidth : 2 ,
5159 backgroundColor : 'green'
@@ -59,6 +67,10 @@ interface TouchViewState {
5967 view3TouchResponderTestStart : boolean ;
6068 view3TouchResponderTestGrant : boolean ;
6169 view3TouchResponderTestRelease : boolean ;
70+ touchPositionOnPage : {
71+ x : number | null
72+ y : number | null
73+ } ;
6274 nestedViewTouchTestParent : boolean ;
6375 nestedViewTouchTestChild : boolean ;
6476 pressEvent ?: RX . Types . TouchEvent ;
@@ -75,6 +87,10 @@ class ViewTouch extends RX.Component<RX.CommonProps, TouchViewState> {
7587 view3TouchResponderTestStart : false ,
7688 view3TouchResponderTestGrant : false ,
7789 view3TouchResponderTestRelease : false ,
90+ touchPositionOnPage : {
91+ x : null ,
92+ y : null
93+ } ,
7894 nestedViewTouchTestParent : false ,
7995 nestedViewTouchTestChild : false ,
8096 } ;
@@ -83,7 +99,7 @@ class ViewTouch extends RX.Component<RX.CommonProps, TouchViewState> {
8399 private static getTouchEventText ( touchEvent ?: RX . Types . TouchEvent ) : string {
84100 if ( touchEvent ) {
85101 return 'altKey = ' + touchEvent . altKey +
86- ' changedTouches.length = ' + touchEvent . changedTouches . length +
102+ ' changedTouches.length = ' + ( touchEvent . changedTouches && touchEvent . changedTouches . length ) +
87103 ' ctrlKey = ' + touchEvent . ctrlKey +
88104 ' metaKey = ' + touchEvent . metaKey +
89105 ' shiftKey = ' + touchEvent . shiftKey +
@@ -171,6 +187,27 @@ class ViewTouch extends RX.Component<RX.CommonProps, TouchViewState> {
171187 } }
172188 />
173189 </ RX . View >
190+ < RX . View style = { _styles . explainTextContainer } >
191+ < RX . Text style = { _styles . explainText } >
192+ { 'When touching this view, it will display the page coordinates of the touch position.' }
193+ </ RX . Text >
194+ </ RX . View >
195+ < RX . View
196+ style = { _styles . testContainer4 }
197+ onResponderMove = { e => {
198+ const touch = e . touches [ 0 ] ;
199+ if ( touch ) {
200+ this . setState ( { touchPositionOnPage : {
201+ x : Math . round ( touch . pageX ) ,
202+ y : Math . round ( touch . pageY )
203+ } } ) ;
204+ }
205+ } }
206+ >
207+ < RX . Text style = { _styles . labelText } >
208+ { `Touch position on page: x: ${ this . state . touchPositionOnPage . x } y: ${ this . state . touchPositionOnPage . y } ` }
209+ </ RX . Text >
210+ </ RX . View >
174211 </ RX . View >
175212 ) ;
176213 }
0 commit comments