Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/Space.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -268,9 +271,11 @@ export class Space extends React.PureComponent<SpaceProps, SpaceState> {
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;
}
}
Expand Down Expand Up @@ -298,6 +303,12 @@ export class Space extends React.PureComponent<SpaceProps, SpaceState> {
};

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) {
Expand Down
7 changes: 7 additions & 0 deletions src/ViewPort.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down