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

@ng-web-apis/resize-observer

Package Overview
Dependencies
Maintainers
0
Versions
40
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ng-web-apis/resize-observer

A library for declarative use of Resize Observer API with Angular

  • 4.11.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
13K
increased by0.46%
Maintainers
0
Weekly downloads
 
Created
Source

ng-web-apis logo Resize Observer API for Angular

npm version npm bundle size codecov

This is a library for declarative use of Resize Observer API with Angular.

Install

If you do not have @ng-web-apis/common:

npm i @ng-web-apis/common

Now install the package:

npm i @ng-web-apis/resize-observer

Usage

  1. Import ResizeObserverModule to the module where you plan to use it.
  2. Use waResizeObserver directive to observe an element:
<section>
  <h1
    waResizeBox="content-box"
    (waResizeObserver)="onResize($event)"
  >
    I'm being observed
  </h1>
</section>

Use waResizeBox to configure ResizeObserver options

NOTE: Keep in mind these are used one time in constructor so you cannot use binding, only strings.

Service

Alternatively you can use Observable-based ResizeObserverService and provide token RESIZE_OPTION_BOX manually:

@Component({
  selector: 'my-component',
  providers: [
    ResizeObserverService,
    {
      provide: RESIZE_OPTION_BOX,
      useValue: 'border-box',
    },
  ],
})
export class Example {
  constructor(@Inject(ResizeObserverService) entries$: ResizeObserverService) {
    entries$.subscribe((entries) => {
      // This will trigger when the component resizes
      // Don't forget to unsubscribe
      console.log(entries);
    });
  }
}

Browser support

IE / Edge
Firefox
Chrome
Safari
iOS Safari
79+69+64+13.1+13.4+

You can use polyfill to support older browsers

Demo

You can try online demo here

See also

Other Web APIs for Angular by @ng-web-apis

Keywords

FAQs

Package last updated on 14 Oct 2024

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