Skip to content

Commit

Permalink
Expose GestureEvent Type
Browse files Browse the repository at this point in the history
  • Loading branch information
SE2Dev committed Sep 13, 2022
1 parent fd9e810 commit c0a8307
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/gestures/Gesture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ type GestureParameterValue = number | boolean | null | Vector;
type SinglePointerInputConstructor = new (...args: ConstructorParameters<typeof SinglePointerInput>) => SinglePointerInput;
type DualPointerInputConstructor = new (...args: ConstructorParameters<typeof DualPointerInput>) => DualPointerInput;

export const GestureEvent = CustomEvent<GestureEventData>;

export interface GestureOptions {
DEBUG: boolean;
blocks: Gesture[];
Expand Down Expand Up @@ -411,7 +413,7 @@ export abstract class Gesture {
bubbles: this.options.bubbles,
};

const event = new CustomEvent(eventName, eventOptions);
const event = new GestureEvent(eventName, eventOptions);

if (eventOptions.bubbles == true) {
target.dispatchEvent(event);
Expand All @@ -424,7 +426,7 @@ export abstract class Gesture {

const hasSupportedDirections = !!this.options.supportedDirections;
// do not fire events like "panendleft"
// only fire directional events if eventName == this.eventBaseName
// only fire directional events if eventName == this.eventBaseName
if (hasSupportedDirections == true && currentDirection != Direction.None && (eventName == this.eventBaseName || eventName == "swipe")) {
for (let d = 0; d < this.options.supportedDirections.length; d++) {
const direction = this.options.supportedDirections[d];
Expand Down Expand Up @@ -523,4 +525,4 @@ export abstract class Gesture {
throw new Error("Gesture subclasses require a getEventData method()");
}

}
}
2 changes: 2 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ export { Geometry } from "./geometry/Geometry";

export { PointerListener } from "./PointerListener";

export { GestureEvent } from "./gestures/Gesture";

export { Tap } from "./gestures/Tap";
export { Press } from "./gestures/Press";
export { Pan } from "./gestures/Pan";
Expand Down

0 comments on commit c0a8307

Please sign in to comment.