11
11
12
12
"use strict" ;
13
13
14
- import { ViroARPlaneSizes , ViroPlaneUpdatedMap } from "../Types/ViroEvents" ;
14
+ import {
15
+ ViroARPlaneSizes ,
16
+ ViroClickStateEvent ,
17
+ ViroPlaneUpdatedMap ,
18
+ } from "../Types/ViroEvents" ;
15
19
import { ViroARPlaneType , ViroNativeRef } from "../Types/ViroUtils" ;
16
20
import * as React from "react" ;
17
21
import { ViroMaterials } from "../Material/ViroMaterials" ;
@@ -65,9 +69,9 @@ export class ViroARPlaneSelector extends React.Component<Props, State> {
65
69
66
70
_getARPlanes ( ) {
67
71
if ( this . state . selectedSurface == - 1 ) {
68
- let arPlanes = [ ] ;
72
+ let arPlanes : JSX . Element [ ] = [ ] ;
69
73
let numPlanes = this . props . maxPlanes || _maxPlanes ;
70
- for ( var i = 0 ; i < numPlanes ; i ++ ) {
74
+ for ( let i = 0 ; i < numPlanes ; i ++ ) {
71
75
let foundARPlane = this . state . foundARPlanes [ i ] ;
72
76
let surfaceWidth = foundARPlane ? foundARPlane . width : 0 ;
73
77
let surfaceHeight = foundARPlane ? foundARPlane . height : 0 ;
@@ -82,7 +86,9 @@ export class ViroARPlaneSelector extends React.Component<Props, State> {
82
86
>
83
87
< ViroQuad
84
88
materials = { "ViroARPlaneSelector_Translucent" }
85
- onClick = { this . _getOnClickSurface ( i ) }
89
+ onClickState = { ( clickState , position , source ) =>
90
+ this . _getOnClickSurface ( i , { clickState, position, source } )
91
+ }
86
92
position = { surfacePosition }
87
93
width = { surfaceWidth }
88
94
height = { surfaceHeight }
@@ -102,17 +108,20 @@ export class ViroARPlaneSelector extends React.Component<Props, State> {
102
108
}
103
109
}
104
110
105
- _getOnClickSurface = ( index : number ) => {
106
- return ( ) => {
107
- this . setState ( { selectedSurface : index } ) ;
108
- this . _onPlaneSelected ( this . state . foundARPlanes [ index ] ) ;
109
- } ;
111
+ _getOnClickSurface = ( index : number , event : ViroClickStateEvent ) => {
112
+ if ( event . clickState < 3 ) {
113
+ return ;
114
+ }
115
+ this . setState ( { selectedSurface : index } ) ;
116
+ this . _onPlaneSelected ( this . state . foundARPlanes [ index ] ) ;
110
117
} ;
111
118
112
119
_onARPlaneUpdated = ( index : number ) => {
113
120
return ( updateMap : ViroPlaneUpdatedMap ) => {
114
- this . state . foundARPlanes [ index ] = updateMap ;
121
+ let newPlanes = [ ...this . state . foundARPlanes ] ;
122
+ newPlanes [ index ] = updateMap ;
115
123
this . setState ( {
124
+ foundARPlanes : newPlanes ,
116
125
arPlaneSizes : this . state . arPlaneSizes ,
117
126
} ) ;
118
127
} ;
0 commit comments