Skip to content

Commit b4cceb9

Browse files
update: Fix ViroARPlaneSelector
1 parent 97119b1 commit b4cceb9

File tree

9 files changed

+38
-26
lines changed

9 files changed

+38
-26
lines changed

components/AR/ViroARPlaneSelector.tsx

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,11 @@
1111

1212
"use strict";
1313

14-
import { ViroARPlaneSizes, ViroPlaneUpdatedMap } from "../Types/ViroEvents";
14+
import {
15+
ViroARPlaneSizes,
16+
ViroClickStateEvent,
17+
ViroPlaneUpdatedMap,
18+
} from "../Types/ViroEvents";
1519
import { ViroARPlaneType, ViroNativeRef } from "../Types/ViroUtils";
1620
import * as React from "react";
1721
import { ViroMaterials } from "../Material/ViroMaterials";
@@ -65,9 +69,9 @@ export class ViroARPlaneSelector extends React.Component<Props, State> {
6569

6670
_getARPlanes() {
6771
if (this.state.selectedSurface == -1) {
68-
let arPlanes = [];
72+
let arPlanes: JSX.Element[] = [];
6973
let numPlanes = this.props.maxPlanes || _maxPlanes;
70-
for (var i = 0; i < numPlanes; i++) {
74+
for (let i = 0; i < numPlanes; i++) {
7175
let foundARPlane = this.state.foundARPlanes[i];
7276
let surfaceWidth = foundARPlane ? foundARPlane.width : 0;
7377
let surfaceHeight = foundARPlane ? foundARPlane.height : 0;
@@ -82,7 +86,9 @@ export class ViroARPlaneSelector extends React.Component<Props, State> {
8286
>
8387
<ViroQuad
8488
materials={"ViroARPlaneSelector_Translucent"}
85-
onClick={this._getOnClickSurface(i)}
89+
onClickState={(clickState, position, source) =>
90+
this._getOnClickSurface(i, { clickState, position, source })
91+
}
8692
position={surfacePosition}
8793
width={surfaceWidth}
8894
height={surfaceHeight}
@@ -102,17 +108,20 @@ export class ViroARPlaneSelector extends React.Component<Props, State> {
102108
}
103109
}
104110

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]);
110117
};
111118

112119
_onARPlaneUpdated = (index: number) => {
113120
return (updateMap: ViroPlaneUpdatedMap) => {
114-
this.state.foundARPlanes[index] = updateMap;
121+
let newPlanes = [...this.state.foundARPlanes];
122+
newPlanes[index] = updateMap;
115123
this.setState({
124+
foundARPlanes: newPlanes,
116125
arPlaneSizes: this.state.arPlaneSizes,
117126
});
118127
};

components/Utilities/ViroVersion.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export const VIRO_VERSION = "2.41.3";
1+
export const VIRO_VERSION = "2.41.4";

components/ViroText.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ export class ViroText extends ViroBase<Props> {
100100
// Fixes #272. for some reason, onClick was making it
101101
// to the native code. Other incorrect props don't make it
102102
// to the native code.
103-
// https://github.com/NativeVision/viro/issues/272
103+
// https://github.com/ReactVision/viro/issues/272
104104
onClick={undefined}
105105
onTouchViro={this._onTouch}
106106
onScrollViro={this._onScroll}

dist/components/AR/ViroARPlaneSelector.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
* @providesModule ViroARPlaneSelector
1010
*/
11-
import { ViroARPlaneSizes, ViroPlaneUpdatedMap } from "../Types/ViroEvents";
11+
import { ViroARPlaneSizes, ViroClickStateEvent, ViroPlaneUpdatedMap } from "../Types/ViroEvents";
1212
import { ViroARPlaneType, ViroNativeRef } from "../Types/ViroUtils";
1313
import * as React from "react";
1414
import { ViroCommonProps, ViroObjectProps } from "./ViroCommonProps";
@@ -38,7 +38,7 @@ export declare class ViroARPlaneSelector extends React.Component<Props, State> {
3838
};
3939
render(): JSX.Element;
4040
_getARPlanes(): JSX.Element | JSX.Element[];
41-
_getOnClickSurface: (index: number) => () => void;
41+
_getOnClickSurface: (index: number, event: ViroClickStateEvent) => void;
4242
_onARPlaneUpdated: (index: number) => (updateMap: ViroPlaneUpdatedMap) => void;
4343
_onPlaneSelected: (updateMap: ViroPlaneUpdatedMap) => void;
4444
reset: () => void;

dist/components/AR/ViroARPlaneSelector.js

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,13 @@ class ViroARPlaneSelector extends React.Component {
6262
if (this.state.selectedSurface == -1) {
6363
let arPlanes = [];
6464
let numPlanes = this.props.maxPlanes || _maxPlanes;
65-
for (var i = 0; i < numPlanes; i++) {
65+
for (let i = 0; i < numPlanes; i++) {
6666
let foundARPlane = this.state.foundARPlanes[i];
6767
let surfaceWidth = foundARPlane ? foundARPlane.width : 0;
6868
let surfaceHeight = foundARPlane ? foundARPlane.height : 0;
6969
let surfacePosition = foundARPlane ? foundARPlane.center : [0, 0, 0];
7070
arPlanes.push(<ViroARPlane_1.ViroARPlane key={_planePrefix + i} minWidth={this.props.minWidth} minHeight={this.props.minHeight} alignment={this.props.alignment} onAnchorUpdated={this._onARPlaneUpdated(i)}>
71-
<ViroQuad_1.ViroQuad materials={"ViroARPlaneSelector_Translucent"} onClick={this._getOnClickSurface(i)} position={surfacePosition} width={surfaceWidth} height={surfaceHeight} rotation={[-90, 0, 0]}/>
71+
<ViroQuad_1.ViroQuad materials={"ViroARPlaneSelector_Translucent"} onClickState={(clickState, position, source) => this._getOnClickSurface(i, { clickState, position, source })} position={surfacePosition} width={surfaceWidth} height={surfaceHeight} rotation={[-90, 0, 0]}/>
7272
</ViroARPlane_1.ViroARPlane>);
7373
}
7474
return arPlanes;
@@ -77,16 +77,19 @@ class ViroARPlaneSelector extends React.Component {
7777
return (<ViroARPlane_1.ViroARPlane key={_planePrefix + this.state.selectedSurface} {...this.props}></ViroARPlane_1.ViroARPlane>);
7878
}
7979
}
80-
_getOnClickSurface = (index) => {
81-
return () => {
82-
this.setState({ selectedSurface: index });
83-
this._onPlaneSelected(this.state.foundARPlanes[index]);
84-
};
80+
_getOnClickSurface = (index, event) => {
81+
if (event.clickState < 3) {
82+
return;
83+
}
84+
this.setState({ selectedSurface: index });
85+
this._onPlaneSelected(this.state.foundARPlanes[index]);
8586
};
8687
_onARPlaneUpdated = (index) => {
8788
return (updateMap) => {
88-
this.state.foundARPlanes[index] = updateMap;
89+
let newPlanes = [...this.state.foundARPlanes];
90+
newPlanes[index] = updateMap;
8991
this.setState({
92+
foundARPlanes: newPlanes,
9093
arPlaneSizes: this.state.arPlaneSizes,
9194
});
9295
};
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export declare const VIRO_VERSION = "2.41.3";
1+
export declare const VIRO_VERSION = "2.41.4";
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
"use strict";
22
Object.defineProperty(exports, "__esModule", { value: true });
33
exports.VIRO_VERSION = void 0;
4-
exports.VIRO_VERSION = "2.41.3";
4+
exports.VIRO_VERSION = "2.41.4";

dist/components/ViroText.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ class ViroText extends ViroBase_1.ViroBase {
7777
// Fixes #272. for some reason, onClick was making it
7878
// to the native code. Other incorrect props don't make it
7979
// to the native code.
80-
// https://github.com/NativeVision/viro/issues/272
80+
// https://github.com/ReactVision/viro/issues/272
8181
onClick={undefined} onTouchViro={this._onTouch} onScrollViro={this._onScroll} onSwipeViro={this._onSwipe} onDragViro={this._onDrag} onPinchViro={this._onPinch} onRotateViro={this._onRotate} onFuseViro={this._onFuse} onAnimationStartViro={this._onAnimationStart} onAnimationFinishViro={this._onAnimationFinish} materials={materials} transformBehaviors={transformBehaviors} outerStroke={outerStroke} canCollide={this.props.onCollision != undefined} onCollisionViro={this._onCollision} timeToFuse={timeToFuse}/>);
8282
}
8383
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"main": "dist/index.js",
44
"module": "dist/index.js",
55
"types": "dist/index.d.ts",
6-
"version": "2.41.3",
6+
"version": "2.41.4",
77
"license": "MIT",
88
"publishConfig": {
99
"registry": "https://registry.npmjs.org/"

0 commit comments

Comments
 (0)