Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ember-on-resize-modifier

Package Overview
Dependencies
Maintainers
3
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ember-on-resize-modifier

Modifier relying on a single ResizeObserver instance for better performance.

  • 2.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
14K
decreased by-10%
Maintainers
3
Weekly downloads
 
Created
Source

{{on-resize}} modifier

CI status NPM version

{{on-resize}} modifier allows to use ResizeObserver to respond to an element's size changes. It relies on a single ResizeObserver instance to achieve better performance (using multiple instances can result in a noticeable performance penalty).

It has good test coverage and is ready for production👍

Installation

ember install ember-on-resize-modifier

If you need a ResizeObserver polyfill (caniuse.com):

ember install ember-resize-observer-polyfill

Usage

<div {{on-resize callback}} />

The callback will be called:

  • when the element is inserted to the DOM
  • whenever the size of the element changes
  • when element.style.display gets set to none (then all contentRect props will be 0)

The callback will be always called with the only argument wich is ResizeObserverEntry object.

Example

<div {{on-resize this.handleResize}}>
  Resize me
</div>
@action
handleResize({ contentRect: { width, height } }) {
  target.classList.toggle('large', width > 1200);
  target.classList.toggle('portrait', height > width);
}

Compatibility

  • Ember.js v3.20 or above
  • Ember CLI v3.20 or above
  • Node.js v12 or above

Contributing

See the Contributing guide for details.

License

This project is licensed under the MIT License.

Keywords

FAQs

Package last updated on 24 Mar 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc