@thatopen/components 2.4.0-alpha.2 → 2.4.0-alpha.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core/Types/src/async-event.d.ts +4 -0
- package/dist/core/Types/src/event-manager.d.ts +30 -0
- package/dist/core/Types/src/event.d.ts +4 -0
- package/dist/core/Types/src/index.d.ts +1 -0
- package/dist/core/Types/src/interfaces.d.ts +10 -0
- package/dist/index.cjs +15 -15
- package/dist/index.mjs +62 -10
- package/dist/namespace.d.ts +3427 -3379
- package/package.json +1 -1
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
* Simple event handler by [Jason Kleban](https://gist.github.com/JasonKleban/50cee44960c225ac1993c922563aa540). Keep in mind that if you want to remove it later, you might want to declare the callback as an object. If you want to maintain the reference to `this`, you will need to declare the callback as an arrow function.
|
|
3
3
|
*/
|
|
4
4
|
export declare class AsyncEvent<T> {
|
|
5
|
+
/**
|
|
6
|
+
* Whether this event is active or not. If not, it won't trigger.
|
|
7
|
+
*/
|
|
8
|
+
enabled: boolean;
|
|
5
9
|
/**
|
|
6
10
|
* Add a callback to this event instance.
|
|
7
11
|
* @param handler - the callback to be added to this event.
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Event } from "./event";
|
|
2
|
+
import { AsyncEvent } from "./async-event";
|
|
3
|
+
/**
|
|
4
|
+
* Simple class to easily toggle and reset event lists.
|
|
5
|
+
*/
|
|
6
|
+
export declare class EventManager {
|
|
7
|
+
/**
|
|
8
|
+
* The list of events managed by this instance.
|
|
9
|
+
*/
|
|
10
|
+
list: Set<Event<any> | AsyncEvent<any>>;
|
|
11
|
+
/**
|
|
12
|
+
* Adds events to this manager.
|
|
13
|
+
* @param events the events to add.
|
|
14
|
+
*/
|
|
15
|
+
add(events: Iterable<Event<any> | AsyncEvent<any>>): void;
|
|
16
|
+
/**
|
|
17
|
+
* Removes events from this manager.
|
|
18
|
+
* @param events the events to remove.
|
|
19
|
+
*/
|
|
20
|
+
remove(events: Iterable<Event<any> | AsyncEvent<any>>): void;
|
|
21
|
+
/**
|
|
22
|
+
* Sets all the events managed by this instance as enabled or disabled.
|
|
23
|
+
* @param active whether to turn on or off the events.
|
|
24
|
+
*/
|
|
25
|
+
set(active: boolean): void;
|
|
26
|
+
/**
|
|
27
|
+
* Resets all the events managed by this instance.
|
|
28
|
+
*/
|
|
29
|
+
reset(): void;
|
|
30
|
+
}
|
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
* Simple event handler by [Jason Kleban](https://gist.github.com/JasonKleban/50cee44960c225ac1993c922563aa540). Keep in mind that if you want to remove it later, you might want to declare the callback as an object. If you want to maintain the reference to `this`, you will need to declare the callback as an arrow function.
|
|
3
3
|
*/
|
|
4
4
|
export declare class Event<T> {
|
|
5
|
+
/**
|
|
6
|
+
* Whether this event is active or not. If not, it won't trigger.
|
|
7
|
+
*/
|
|
8
|
+
enabled: boolean;
|
|
5
9
|
/**
|
|
6
10
|
* Add a callback to this event instance.
|
|
7
11
|
* @param handler - the callback to be added to this event.
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as THREE from "three";
|
|
2
2
|
import CameraControls from "camera-controls";
|
|
3
3
|
import { Event } from "./event";
|
|
4
|
+
import { EventManager } from "./event-manager";
|
|
4
5
|
/**
|
|
5
6
|
* Whether this component has to be manually destroyed once you are done with it to prevent [memory leaks](https://threejs.org/docs/#manual/en/introduction/How-to-dispose-of-objects). This also ensures that the DOM events created by that component will be cleaned up.
|
|
6
7
|
*/
|
|
@@ -105,3 +106,12 @@ export interface CameraControllable {
|
|
|
105
106
|
*/
|
|
106
107
|
controls: CameraControls;
|
|
107
108
|
}
|
|
109
|
+
/**
|
|
110
|
+
* Whether it has events or not.
|
|
111
|
+
*/
|
|
112
|
+
export interface Eventable {
|
|
113
|
+
/**
|
|
114
|
+
* The object in charge of managing all the events.
|
|
115
|
+
*/
|
|
116
|
+
eventManager: EventManager;
|
|
117
|
+
}
|