First Commit

This commit is contained in:
2025-08-07 20:20:36 +02:00
parent 025d539fc5
commit 21f637fcec
37 changed files with 4620 additions and 0 deletions

View File

@@ -0,0 +1,17 @@
export class EventsManager {
events: { target: EventTarget, type: string, handler: EventListenerOrEventListenerObject }[] = [];
addEvent<K extends keyof DocumentEventMap>(target: EventTarget, type: K, handler: (e: DocumentEventMap[K]) => void) {
// @ts-expect-error
this.events.push({ target, type, handler });
// @ts-expect-error
target.addEventListener(type, handler);
}
destroy() {
this.events.forEach((e) => {
e.target.removeEventListener(e.type, e.handler);
});
}
}