-
-
Notifications
You must be signed in to change notification settings - Fork 82
/
tp-event.ts
103 lines (90 loc) · 1.79 KB
/
tp-event.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
/**
* A base class for Tweakpane API events.
* @template Target The event target.
*/
export class TpEvent<Target = unknown> {
/**
* The event dispatcher.
*/
public readonly target: Target;
/**
* @hidden
*/
constructor(target: Target) {
this.target = target;
}
}
/**
* An event class for value changes.
* @template T The type of the value.
* @template Target The event target.
*/
export class TpChangeEvent<T, Target = unknown> extends TpEvent<Target> {
/**
* The value.
*/
public readonly value: T;
/**
* The flag indicating whether the event is for the last change.
*/
public readonly last: boolean;
/**
* @hidden
*/
constructor(target: Target, value: T, last?: boolean) {
super(target);
this.value = value;
this.last = last ?? true;
}
}
/**
* An event class for folder.
* @template Target The event target.
*/
export class TpFoldEvent<Target> extends TpEvent<Target> {
/**
* The current state of the folder expansion.
*/
public readonly expanded: boolean;
/**
* @hidden
*/
constructor(target: Target, expanded: boolean) {
super(target);
this.expanded = expanded;
}
}
/**
* An event class for tab selection.
* @template Target The event target.
*/
export class TpTabSelectEvent<Target> extends TpEvent<Target> {
/**
* The selected index of the tab item.
*/
public readonly index: number;
/**
* @hidden
*/
constructor(target: Target, index: number) {
super(target);
this.index = index;
}
}
/**
* An event class for mouse events.
* @template Target The event target.
*/
export class TpMouseEvent<Target> extends TpEvent<Target> {
/**
* The native mouse event.
*/
public readonly native: MouseEvent;
/**
* @hidden
*/
constructor(target: Target, nativeEvent: MouseEvent) {
super(target);
this.native = nativeEvent;
}
}