-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
DroppableEvent.ts
138 lines (121 loc) · 2.99 KB
/
DroppableEvent.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
import AbstractEvent from 'shared/AbstractEvent';
import {DragEvent, DragEventData} from '../../Draggable/DragEvent';
interface DroppableEventData {
dragEvent: DragEvent<DragEventData>;
}
/**
* Base droppable event
* @class DroppableEvent
* @module DroppableEvent
* @extends AbstractEvent
*/
export class DroppableEvent<
T extends DroppableEventData,
> extends AbstractEvent<DroppableEventData> {
static type = 'droppable';
/**
* DroppableEvent constructor.
* @constructs DroppableEvent
* @param {DroppableEventData} data - Event data
*/
constructor(public data: T) {
super(data);
}
/**
* Original drag event that triggered this droppable event
* @property dragEvent
* @type {DragEvent}
* @readonly
*/
get dragEvent() {
return this.data.dragEvent;
}
}
interface DroppableStartEventData extends DroppableEventData {
dropzone: HTMLElement;
}
/**
* Droppable start event
* @class DroppableStartEvent
* @module DroppableStartEvent
* @extends DroppableEvent
*/
export class DroppableStartEvent extends DroppableEvent<DroppableStartEventData> {
static type = 'droppable:start';
static cancelable = true;
/**
* The initial dropzone element of the currently dragging draggable element
* @property dropzone
* @type {HTMLElement}
* @readonly
*/
get dropzone() {
return this.data.dropzone;
}
}
interface DroppableDroppedEventData extends DroppableEventData {
dropzone: HTMLElement;
}
/**
* Droppable dropped event
* @class DroppableDroppedEvent
* @module DroppableDroppedEvent
* @extends DroppableEvent
*/
export class DroppableDroppedEvent extends DroppableEvent<DroppableDroppedEventData> {
static type = 'droppable:dropped';
static cancelable = true;
/**
* The dropzone element you dropped the draggable element into
* @property dropzone
* @type {HTMLElement}
* @readonly
*/
get dropzone() {
return this.data.dropzone;
}
}
interface DroppableReturnedEventData extends DroppableEventData {
dropzone: HTMLElement;
}
/**
* Droppable returned event
* @class DroppableReturnedEvent
* @module DroppableReturnedEvent
* @extends DroppableEvent
*/
export class DroppableReturnedEvent extends DroppableEvent<DroppableReturnedEventData> {
static type = 'droppable:returned';
static cancelable = true;
/**
* The dropzone element you dragged away from
* @property dropzone
* @type {HTMLElement}
* @readonly
*/
get dropzone() {
return this.data.dropzone;
}
}
interface DroppableStopEventData extends DroppableEventData {
dropzone: HTMLElement;
}
/**
* Droppable stop event
* @class DroppableStopEvent
* @module DroppableStopEvent
* @extends DroppableEvent
*/
export class DroppableStopEvent extends DroppableEvent<DroppableStopEventData> {
static type = 'droppable:stop';
static cancelable = true;
/**
* The final dropzone element of the draggable element
* @property dropzone
* @type {HTMLElement}
* @readonly
*/
get dropzone() {
return this.data.dropzone;
}
}