1.0.4 • Published 4 years ago

resize-observer v1.0.4

Weekly downloads
49,130
License
Apache-2.0
Repository
github
Last release
4 years ago

resize-observer

Build Status NPM Version

npm bundle size (minified + gzip)

This library aims to be a faithful implementation and ponyfill of the Resize Observer draft. An optional polyfill option exists as well.

Installation

resize-observer is available on NPM and Yarn:

> npm install resize-observer
> yarn add resize-observer

Setup

As a ponyfill/module

resize-observer does not install itself by default. As such, you can import it like any other module:

import { ResizeObserver } from 'resize-observer';

const ro = new ResizeObserver(() => console.log('resize observed!'));
ro.observe(document.body);

As a polyfill

resize-observer provides a file that can be referenced from your browser that automatically installs ResizeObserver on the global window object. Both minified and non-minified versions exist, and are found in the package under the dist/ directory:

<script src="/node_modules/resize-observer/dist/resize-observer.js"></script>
<script type="text/javascript">
  const ro = new window.ResizeObserver(() => alert('Observing things is super cool!'));
  /* use your ResizeObserver! */
</script>

A install method is also provided to do the same within your own code:

import { install } from 'resize-observer';

install();

const ro = new window.ResizeObserver(() => alert('Observe all the things!'));
/* ... */

Note: Calling install will always overwrite window.ResizeObserver. If you'd like to only install resize-observer when it doesn't already exist, you can add a simple check before calling install:

import { install } from 'resize-observer';

if (!window.ResizeObserver) install();

/* ... */

TypeScript definitions

resize-observer is written in TypeScript. The definition files are included in the package and should be picked up automatically.

@typetura/corereact-flow-dnd@eroad/vue-cli-plugin-resize-observer-polyfillmedbelle-ui-v4medbelle-ui-v6alphakit-ui@linnworks/linn.core.clientrendition@everything-registry/sub-chunk-2656test-publish-lamluu-4@dims/scrollnavlacront-core-componentsstyled-container-querytypescript-react-table-custom@andreisergiu98/amazon-chime-sdk-js@aics/fms-file-explorer-core@alphakits/ui@beakerx/beakerx-tabledisplay@buckneri/web-components@chax-at/amazon-chime-sdk-js@activfinancial/time-series-chart@activfinancial/option-chain@coderehab/greenzine-react-deprecated@dataartdev/uikit@crpt/react-selectzack-search@raisenow/tamaro-core@flexis/ui@elliemae/ds-legacy-form@giant-fe/workflow-designer@infologistics/frontend-libraries@kubevious/ui-components@lxsmnsyc/indigo-player@nnno/manto-utils@nnno/manto-utils-v2@jramineni/beakerx-tabledisplay@rayvid/amazon-chime-sdk-js@openremote/or-rules@piccollage/cbjs@pocketprep/ui-kit@pattern-x/gemini-viewer-ue-web@orangesk/orange-design-system@organisme/ui@overdose/components@sme.up/ketchupmod-amazon-chime-sdk-jsmjg_bundle_sdk_reactolymcroot-frontreact-dynamic-grid-systemreact-neonnetwork-policy-viewernext-grid-dndrespornl-vendor-mfernl-vendor-uisitteneturmango-vuemanto-test-librarymediafly-document-component@wallneradam/output_auto_scroll@wcd/anoblet.responsive-menu@wrld/canvas-geometry-editor@the-toucan/twc@vertexvis/viewer@yangwch/y-components@talkfurther/elementsamazon-chime-es-sdkamazon-chime-sdkamazon-chime-sdk-jsalphakit_v2canvas-formsconverteme-componentsdb-web-basedbl-componentses-componentsernie-amazon-chime-sdk-jsframework-entersol-web
1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

7 years ago

1.0.0-alpha.1

7 years ago

1.0.0-alpha.0

7 years ago

0.1.1

7 years ago

0.1.0

7 years ago

0.0.4

9 years ago

0.0.3

9 years ago

0.0.2

9 years ago

0.0.1

9 years ago