add scroll and viewport resize observers

This commit is contained in:
Yanzhen Yu
2018-10-09 10:33:24 +08:00
parent 64d4c541ee
commit 1f10b70d30
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: {},