A custom element that offers a declarative interface to the ResizeObserver API.
$ npm install --save @georapbox/resize-observer-element
import { ResizeObserverElement } from './node_modules/@georapbox/resize-observer-element/dist/resize-observer.js';
// Manually define the element.
ResizeObserverElement.defineCustomElement();
Alternatively, you can import the automatically defined custom element.
import './node_modules/@georapbox/resize-observer-element/dist/resize-observer-defined.js';
<resize-observer>
<p>Lorem, ipsum dolor sit amet consectetur adipisicing elit.</p>
<p>Quas quo aliquam iure ipsa laborum! Deleniti doloremque quaerat sunt, esse fugit.</p>
<p>Molestias, libero laborum minus facere ullam iusto eius in adipisci quaerat autem placeat quisquam.</p>
</resize-observer>
Name | Reflects | Type | Default | Description |
---|---|---|---|---|
disabled |
✓ | Boolean | false |
Defines if the resize observer is disabled or not. |
Name | Description |
---|---|
(default) | The default slot where the elements to observe are placed. |
Name | Type | Description | Arguments |
---|---|---|---|
defineCustomElement |
Static | Defines/registers the custom element with the name provided. If no name is provided, the default name is used. The method checks if the element is already defined, hence will skip trying to redefine it. | elementName='resize-observer' |
Name | Description | Event Detail |
---|---|---|
resize-observer:resize |
Emitted when the element is resized. | { entries: ResizeObserverEntry[] |
For API updates and breaking changes, check the CHANGELOG.
The project requires Node.js
and npm
to be installed on your environment. Preferrably, use nvm Node Version Manager and use the version of Node.js specified in the .nvmrc
file by running nvm use
.
Install the project dependencies by running the following command.
npm install
Watch for changes and start a development server by running the following command.
npm start
Lint the code by running the following command.
npm run lint
Run the tests by running any of the following commands.
npm test
npm run test:watch # watch mode
Create a production build by running the following command.
npm run build