0.2.3 • Published 3 months ago

resize-watcher v0.2.3

Weekly downloads
-
License
MIT
Repository
-
Last release
3 months ago

Resize-Watcher

Getting Started

Package manager

Using npm:

npm install resize-watcher

Once the package is installed, you can import the library using import approach:

import { Watcher } from 'resize-watcher'

Example

import { Watcher } from 'resize-watcher'
// DOM
const targetEl = document.getElementById('box')

// create instance
const watcher = Watcher.create(targetEl)

// start watch
watcher.mount()

// end watch
watcher.unmount()

API

Watcher(el, options)

Watcher.create(el, options)

Options

export type ThresholdOptions = {
    range: [number, number];
    handler: (res?: DOMRectReadOnly) => void;
};
export type ResizeWatcherOptions = {
    mode?: 'simple' | 'threshold';
    immediate?: boolean;
    duration?: number;
    handler?: (res?: DOMRectReadOnly) => void;
    threshold?: ThresholdOptions[];
};
export declare class Watcher {
    private el;
    private options;
    constructor(el: HTMLElement, options?: ResizeWatcherOptions);
    static create(el: HTMLElement, options?: ResizeWatcherOptions): Watcher;
    mount(): void;
    unmount(): void;
}
0.2.3

3 months ago

0.2.2

3 months ago

0.2.1

6 months ago

0.2.0

6 months ago

0.1.1

6 months ago

0.1.0

6 months ago