diff --git a/components/AR/ViroARPlaneSelector.tsx b/components/AR/ViroARPlaneSelector.tsx index 255cfd9..fcc6eb4 100644 --- a/components/AR/ViroARPlaneSelector.tsx +++ b/components/AR/ViroARPlaneSelector.tsx @@ -11,7 +11,11 @@ "use strict"; -import { ViroARPlaneSizes, ViroPlaneUpdatedMap } from "../Types/ViroEvents"; +import { + ViroARPlaneSizes, + ViroClickStateEvent, + ViroPlaneUpdatedMap, +} from "../Types/ViroEvents"; import { ViroARPlaneType, ViroNativeRef } from "../Types/ViroUtils"; import * as React from "react"; import { ViroMaterials } from "../Material/ViroMaterials"; @@ -65,9 +69,9 @@ export class ViroARPlaneSelector extends React.Component { _getARPlanes() { if (this.state.selectedSurface == -1) { - let arPlanes = []; + let arPlanes: JSX.Element[] = []; let numPlanes = this.props.maxPlanes || _maxPlanes; - for (var i = 0; i < numPlanes; i++) { + for (let i = 0; i < numPlanes; i++) { let foundARPlane = this.state.foundARPlanes[i]; let surfaceWidth = foundARPlane ? foundARPlane.width : 0; let surfaceHeight = foundARPlane ? foundARPlane.height : 0; @@ -82,7 +86,9 @@ export class ViroARPlaneSelector extends React.Component { > + this._getOnClickSurface(i, { clickState, position, source }) + } position={surfacePosition} width={surfaceWidth} height={surfaceHeight} @@ -102,17 +108,20 @@ export class ViroARPlaneSelector extends React.Component { } } - _getOnClickSurface = (index: number) => { - return () => { - this.setState({ selectedSurface: index }); - this._onPlaneSelected(this.state.foundARPlanes[index]); - }; + _getOnClickSurface = (index: number, event: ViroClickStateEvent) => { + if (event.clickState < 3) { + return; + } + this.setState({ selectedSurface: index }); + this._onPlaneSelected(this.state.foundARPlanes[index]); }; _onARPlaneUpdated = (index: number) => { return (updateMap: ViroPlaneUpdatedMap) => { - this.state.foundARPlanes[index] = updateMap; + let newPlanes = [...this.state.foundARPlanes]; + newPlanes[index] = updateMap; this.setState({ + foundARPlanes: newPlanes, arPlaneSizes: this.state.arPlaneSizes, }); }; diff --git a/components/Utilities/ViroVersion.ts b/components/Utilities/ViroVersion.ts index e37470d..c31711f 100644 --- a/components/Utilities/ViroVersion.ts +++ b/components/Utilities/ViroVersion.ts @@ -1 +1 @@ -export const VIRO_VERSION = "2.41.3"; +export const VIRO_VERSION = "2.41.4"; diff --git a/components/ViroText.tsx b/components/ViroText.tsx index 517bd94..1f0b535 100644 --- a/components/ViroText.tsx +++ b/components/ViroText.tsx @@ -100,7 +100,7 @@ export class ViroText extends ViroBase { // Fixes #272. for some reason, onClick was making it // to the native code. Other incorrect props don't make it // to the native code. - // https://github.com/NativeVision/viro/issues/272 + // https://github.com/ReactVision/viro/issues/272 onClick={undefined} onTouchViro={this._onTouch} onScrollViro={this._onScroll} diff --git a/dist/components/AR/ViroARPlaneSelector.d.ts b/dist/components/AR/ViroARPlaneSelector.d.ts index 2ba31f7..52e0ec5 100644 --- a/dist/components/AR/ViroARPlaneSelector.d.ts +++ b/dist/components/AR/ViroARPlaneSelector.d.ts @@ -8,7 +8,7 @@ * * @providesModule ViroARPlaneSelector */ -import { ViroARPlaneSizes, ViroPlaneUpdatedMap } from "../Types/ViroEvents"; +import { ViroARPlaneSizes, ViroClickStateEvent, ViroPlaneUpdatedMap } from "../Types/ViroEvents"; import { ViroARPlaneType, ViroNativeRef } from "../Types/ViroUtils"; import * as React from "react"; import { ViroCommonProps, ViroObjectProps } from "./ViroCommonProps"; @@ -38,7 +38,7 @@ export declare class ViroARPlaneSelector extends React.Component { }; render(): JSX.Element; _getARPlanes(): JSX.Element | JSX.Element[]; - _getOnClickSurface: (index: number) => () => void; + _getOnClickSurface: (index: number, event: ViroClickStateEvent) => void; _onARPlaneUpdated: (index: number) => (updateMap: ViroPlaneUpdatedMap) => void; _onPlaneSelected: (updateMap: ViroPlaneUpdatedMap) => void; reset: () => void; diff --git a/dist/components/AR/ViroARPlaneSelector.js b/dist/components/AR/ViroARPlaneSelector.js index fda8c39..7ce9228 100644 --- a/dist/components/AR/ViroARPlaneSelector.js +++ b/dist/components/AR/ViroARPlaneSelector.js @@ -62,13 +62,13 @@ class ViroARPlaneSelector extends React.Component { if (this.state.selectedSurface == -1) { let arPlanes = []; let numPlanes = this.props.maxPlanes || _maxPlanes; - for (var i = 0; i < numPlanes; i++) { + for (let i = 0; i < numPlanes; i++) { let foundARPlane = this.state.foundARPlanes[i]; let surfaceWidth = foundARPlane ? foundARPlane.width : 0; let surfaceHeight = foundARPlane ? foundARPlane.height : 0; let surfacePosition = foundARPlane ? foundARPlane.center : [0, 0, 0]; arPlanes.push( - + this._getOnClickSurface(i, { clickState, position, source })} position={surfacePosition} width={surfaceWidth} height={surfaceHeight} rotation={[-90, 0, 0]}/> ); } return arPlanes; @@ -77,16 +77,19 @@ class ViroARPlaneSelector extends React.Component { return (); } } - _getOnClickSurface = (index) => { - return () => { - this.setState({ selectedSurface: index }); - this._onPlaneSelected(this.state.foundARPlanes[index]); - }; + _getOnClickSurface = (index, event) => { + if (event.clickState < 3) { + return; + } + this.setState({ selectedSurface: index }); + this._onPlaneSelected(this.state.foundARPlanes[index]); }; _onARPlaneUpdated = (index) => { return (updateMap) => { - this.state.foundARPlanes[index] = updateMap; + let newPlanes = [...this.state.foundARPlanes]; + newPlanes[index] = updateMap; this.setState({ + foundARPlanes: newPlanes, arPlaneSizes: this.state.arPlaneSizes, }); }; diff --git a/dist/components/Utilities/ViroVersion.d.ts b/dist/components/Utilities/ViroVersion.d.ts index a148aa8..5a32e88 100644 --- a/dist/components/Utilities/ViroVersion.d.ts +++ b/dist/components/Utilities/ViroVersion.d.ts @@ -1 +1 @@ -export declare const VIRO_VERSION = "2.41.3"; +export declare const VIRO_VERSION = "2.41.4"; diff --git a/dist/components/Utilities/ViroVersion.js b/dist/components/Utilities/ViroVersion.js index eca84a2..90badd7 100644 --- a/dist/components/Utilities/ViroVersion.js +++ b/dist/components/Utilities/ViroVersion.js @@ -1,4 +1,4 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.VIRO_VERSION = void 0; -exports.VIRO_VERSION = "2.41.3"; +exports.VIRO_VERSION = "2.41.4"; diff --git a/dist/components/ViroText.js b/dist/components/ViroText.js index 186f6bb..b632520 100644 --- a/dist/components/ViroText.js +++ b/dist/components/ViroText.js @@ -77,7 +77,7 @@ class ViroText extends ViroBase_1.ViroBase { // Fixes #272. for some reason, onClick was making it // to the native code. Other incorrect props don't make it // to the native code. - // https://github.com/NativeVision/viro/issues/272 + // https://github.com/ReactVision/viro/issues/272 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}/>); } } diff --git a/package.json b/package.json index 2a42564..c417796 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "main": "dist/index.js", "module": "dist/index.js", "types": "dist/index.d.ts", - "version": "2.41.3", + "version": "2.41.4", "license": "MIT", "publishConfig": { "registry": "https://registry.npmjs.org/"