diff --git a/src/Space.tsx b/src/Space.tsx index 72be7af..14a291f 100644 --- a/src/Space.tsx +++ b/src/Space.tsx @@ -98,6 +98,9 @@ export interface SpaceProps extends React.PropsWithChildren { * be ignored. */ readonly treatTwoFingerTrackPadGesturesLikeTouch?: boolean; + + //if one of the pressable is seleted + readonly isWheelDisabled?:boolean } interface SpaceState { @@ -268,9 +271,11 @@ export class Space extends React.PureComponent { e: MouseEvent | TouchEvent, coordinates: PressEventCoordinates, ): PressHandlingOptions | undefined => { + if (this.props.onDecideHowToHandlePress) { const result = this.props.onDecideHowToHandlePress(e, coordinates); if (result) { + console.log("result", result) return result; } } @@ -298,6 +303,12 @@ export class Space extends React.PureComponent { }; private handleHover = (e: MouseEvent, coordinates: PressEventCoordinates) => { + if(this.props.isWheelDisabled){ + this.viewPort?.removeWheelListner(); + } + else { + this.viewPort?.addWheelListner(); + } const interactableId = getInteractableIdMostApplicableToElement(e.target as any); const interactable = (interactableId && this.interactableRegistry.get(interactableId)) || undefined; if (interactable && interactable instanceof Pressable) { diff --git a/src/ViewPort.ts b/src/ViewPort.ts index 2549802..f0a66b5 100644 --- a/src/ViewPort.ts +++ b/src/ViewPort.ts @@ -290,6 +290,13 @@ export class ViewPort { this.hammer.destroy(); } + public removeWheelListner(): void { + this.containerDiv.removeEventListener('wheel', this.handleWheel); + } + public addWheelListner(): void { + this.containerDiv.addEventListener('wheel', this.handleWheel, { passive: false }); + } + /** * Constrain the virtual space so the user can not pan beyond, and the camera * cannot show anything beyond, the provided min/max values for x, y, and the