Skip to content

toosoon-dev/toosoon-events

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TOOSOON Events

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.

NPM

Installation

Yarn:

$ yarn add toosoon-events

NPM:

$ npm install toosoon-events

Usage

import PointerManager, { Pointer } from 'toosoon-events/pointer';

function onPointerStart(pointers: Pointers[]) {
  // ...
}

function bind() {
  PointerManager.on('start', onPointerStart);
}

function unbind() {
  PointerManager.off('start', onPointerStart);
}

Managers

KeyboardManager

Utility class for creating keyboard events listeners.

Types

type KeyboardEventKey = 'down' | 'up' | 'press';

type KeyboardListener = (event: KeyboardEvent) => void;

PointerManager

Utility class for creating mouse/touch events listeners.

Types

type Pointer = {
  x: number;
  y: number;
};

type PointerEventKey = 'start' | 'end' | 'move';

type PointerListener = (pointers: Pointer[]) => void;

RafManager

Utility class for creating requestAnimationFrame listeners.

Types

type RafListener = (time: number, delta: number) => void;

Properties

.time
RafListener.time: numbze;

ResizeManager

Utility class for creating resize event listeners.

Types

type ResizeListener = (width: number, height: number) => void;

Properties

.width
ResizeManager.width: numbze;
.height
ResizeManager.height: numbze;

ScrollManager

Utility class for creating scroll event listeners.

Types

type ScrollListener = (event: Event) => void;

License

MIT License, see LICENSE for details.

About

Project providing services implemented as singleton class instances. They abstract and prevent the process of creating multiple event listeners for common browser events. These services are particularly useful for managing events that are likely to be listened to by many components.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors