obsize
TypeScript icon, indicating that this package has built-in type declarations

0.0.2 • Public • Published

obsize

obsize is a tiny library that observes an element's size change.

Browser Compatibility

  • Chrome (64+)
  • Edge (79+)
  • Firefox (69+)
  • Opera (51+)
  • Safari (13.1+)

Install

pnpm add obsize -S
npm install obsize -S
yarn add obsize -S

Useage

import { observe } from "../../src/index";

const unobserve = observe(element, () => { console.log('trigger') });

// call unobserve could remove the observe
unobserve()

API

observe

Observe the size of specified elements.

  • Params
    • element - The element to be observer.
    • fn - The function to call when the element's size has changed.
    • options - Others cofnig.
      • once - It will auto-remove the observer when fn has been called.

clear

Clear all observers for any elements.

License

MIT license.

Package Sidebar

Install

npm i obsize

Weekly Downloads

37

Version

0.0.2

License

MIT

Unpacked Size

261 kB

Total Files

34

Last publish

Collaborators

  • yukiniro