mirror of
https://github.com/BetterSEQTA/BetterSEQTA-Plus.git
synced 2026-06-06 03:34:40 +00:00
feat(notices): add animations to notices
This commit is contained in:
@@ -46,10 +46,27 @@ class EventManager {
|
||||
}
|
||||
const unregister = () => this.unregisterById(event, id);
|
||||
this.listeners.get(event)!.push({ id, options, callback, unregister });
|
||||
|
||||
this.scanExistingElements(options, callback);
|
||||
|
||||
this.startObserving(options.parentElement);
|
||||
return { unregister };
|
||||
}
|
||||
|
||||
private async scanExistingElements(options: EventListenerOptions, callback: (element: Element) => void): Promise<void> {
|
||||
const root = options.parentElement || document.documentElement;
|
||||
const elements = Array.from(root.getElementsByTagName('*'));
|
||||
elements.unshift(root);
|
||||
|
||||
for (let i = 0; i < elements.length; i += this.chunkSize) {
|
||||
const chunk = elements.slice(i, i + this.chunkSize);
|
||||
const filteredChunk = chunk.filter(element => this.matchesOptions(element, options));
|
||||
for (const element of filteredChunk) {
|
||||
callback(element);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public unregister(event: string): void {
|
||||
if (this.listeners.has(event)) {
|
||||
this.listeners.delete(event);
|
||||
|
||||
Reference in New Issue
Block a user