Skip to content

Commit

Permalink
Convert CollidableEvent to typescript
Browse files Browse the repository at this point in the history
  • Loading branch information
tsov committed Sep 28, 2023
1 parent 9154a96 commit bb23ff2
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/calm-kangaroos-jump.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@shopify/draggable': patch
---

Convert CollidableEvent to typescript
Original file line number Diff line number Diff line change
@@ -1,14 +1,31 @@
import AbstractEvent from 'shared/AbstractEvent';

import {DragEvent, DragEventData} from '../../../Draggable/DragEvent';

interface CollidableEventData {
dragEvent: DragEvent<DragEventData>;
}

/**
* Base collidable event
* @class CollidableEvent
* @module CollidableEvent
* @extends AbstractEvent
*/
export class CollidableEvent extends AbstractEvent {
export class CollidableEvent<
T extends CollidableEventData,
> extends AbstractEvent<CollidableEventData> {
static type = 'collidable';

/**
* CollidableEvent constructor.
* @constructs CollidableEvent
* @param {CollidableEventData} data - Event data
*/
constructor(public data: T) {
super(data);
}

/**
* Drag event that triggered this colliable event
* @property dragEvent
Expand All @@ -20,13 +37,17 @@ export class CollidableEvent extends AbstractEvent {
}
}

interface CollidableInEventData extends CollidableEventData {
collidingElement: HTMLElement;
}

/**
* Collidable in event
* @class CollidableInEvent
* @module CollidableInEvent
* @extends CollidableEvent
*/
export class CollidableInEvent extends CollidableEvent {
export class CollidableInEvent extends CollidableEvent<CollidableInEventData> {
static type = 'collidable:in';

/**
Expand All @@ -40,13 +61,17 @@ export class CollidableInEvent extends CollidableEvent {
}
}

interface CollidableOutEventData extends CollidableEventData {
collidingElement: HTMLElement;
}

/**
* Collidable out event
* @class CollidableOutEvent
* @module CollidableOutEvent
* @extends CollidableEvent
*/
export class CollidableOutEvent extends CollidableEvent {
export class CollidableOutEvent extends CollidableEvent<CollidableOutEventData> {
static type = 'collidable:out';

/**
Expand Down

0 comments on commit bb23ff2

Please sign in to comment.