Project providing managers implemented as singleton class instances. They abstract and prevent the process of creating multiple event listeners for common browser events. These managers are particularly useful for managing events that are likely to be listened to by many components.
Yarn:
$ yarn add toosoon-eventsNPM:
$ npm install toosoon-eventsimport PointerManager, { Pointer } from 'toosoon-events/pointer';
function onPointerStart(pointers: Pointers[]) {
// ...
}
function bind() {
PointerManager.on('start', onPointerStart);
}
function unbind() {
PointerManager.off('start', onPointerStart);
}Utility class for creating keyboard events listeners.
type KeyboardEventKey = 'down' | 'up' | 'press';
type KeyboardListener = (event: KeyboardEvent) => void;Utility class for creating mouse/touch events listeners.
type Pointer = {
x: number;
y: number;
};
type PointerEventKey = 'start' | 'end' | 'move';
type PointerListener = (pointers: Pointer[]) => void;Utility class for creating requestAnimationFrame listeners.
type RafListener = (time: number, delta: number) => void;RafListener.time: numbze;Utility class for creating resize event listeners.
type ResizeListener = (width: number, height: number) => void;ResizeManager.width: numbze;ResizeManager.height: numbze;Utility class for creating scroll event listeners.
type ScrollListener = (event: Event) => void;MIT License, see LICENSE for details.
