add scroll and viewport resize observers

This commit is contained in:
Yanzhen Yu
2026-04-01 12:00:00 +08:00
parent 7078ce2f2a
commit ee4fc3ce7e
4 changed files with 121 additions and 29 deletions

View File

@@ -1,4 +1,13 @@
import { Mirror, throttleOptions } from './types';
import { Mirror, throttleOptions, listenerHandler } from './types';
export function on(
type: string,
fn: EventListenerOrEventListenerObject,
target: Document | Window = document,
): listenerHandler {
target.addEventListener(type, fn, { capture: true, passive: true });
return () => target.removeEventListener(type, fn);
}
export const mirror: Mirror = {
map: {},