Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { MouseButton } from '../../handlers/gestureHandlerCommon';
import KeyboardEventManager from './KeyboardEventManager';
import WheelEventManager from './WheelEventManager';
import { tagMessage } from '../../utils';
import HoverGestureHandler from '../handlers/HoverGestureHandler';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we handle that in another way (like a method or property)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, we can after #3729 is merged 😅


interface DefaultViewStyles {
userSelect: string;
Expand Down Expand Up @@ -52,7 +53,11 @@ export class GestureHandlerWebDelegate
this.setTouchAction();
this.setContextMenu();

this.eventManagers.push(new PointerEventManager(this.view));
const shouldSendHoverEvents = handler instanceof HoverGestureHandler;

this.eventManagers.push(
new PointerEventManager(this.view, shouldSendHoverEvents)
);
this.eventManagers.push(new KeyboardEventManager(this.view));
this.eventManagers.push(new WheelEventManager(this.view));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ export default class PointerEventManager extends EventManager<HTMLElement> {
private trackedPointers = new Set<number>();
private readonly mouseButtonsMapper = new Map<number, MouseButton>();
private lastPosition: Point;
private shouldSendHoverEvents: boolean;

constructor(view: HTMLElement) {
constructor(view: HTMLElement, shouldSendHoverEvents: boolean) {
super(view);

this.mouseButtonsMapper.set(0, MouseButton.LEFT);
Expand All @@ -29,6 +30,8 @@ export default class PointerEventManager extends EventManager<HTMLElement> {
x: -Infinity,
y: -Infinity,
};

this.shouldSendHoverEvents = shouldSendHoverEvents;
}

private pointerDownCallback = (event: PointerEvent) => {
Expand Down Expand Up @@ -82,6 +85,10 @@ export default class PointerEventManager extends EventManager<HTMLElement> {
};

private pointerMoveCallback = (event: PointerEvent) => {
if (!this.shouldSendHoverEvents && this.activePointersCounter === 0) {
return;
}

const adaptedEvent: AdaptedEvent = this.mapEvent(event, EventTypes.MOVE);
const target = event.target as HTMLElement;

Expand Down
Loading