Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on May 29, 2023. It is now read-only.

A library for idiomatic use of ResizeObserver with Angular

License

NotificationsYou must be signed in to change notification settings

ng-web-apis/resize-observer



Attention! This repository is archived and the library has been moved totinkoff/ng-web-apis monorepository



ng-web-apis logo Resize Observer API for Angular

Part of >Web APIs for Angular

npm versionnpm bundle size.github/workflows/ci.ymlCoveralls githubangular-open-source-starter

This is a library for declarative use ofResize 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. ImportResizeObserverModule to the module where you plan to use it.
  2. UsewaResizeObserver directive to observe an element:
<section><h1waResizeBox="content-box"(waResizeObserver)="onResize($event)">I'm being observed</h1></section>

UsewaResizeBox to configureResizeObserver options

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

Service

Alternatively you can useObservable-basedResizeObserverService and provide tokenRESIZE_OPTION_BOX manually:

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

Browser support

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

You can usepolyfill to support older browsers

Demo

You cantry online demo here

See also

OtherWeb APIs for Angular by@ng-web-apis

Open-source

Do you also want to open-source something, but hate the collateral work? Check out thisAngular Open-source Library Starter we’ve createdfor our projects. It got you covered on continuous integration, pre-commit checks, linting, versioning + changelog, codecoverage and all that jazz.

About

A library for idiomatic use of ResizeObserver with Angular

Topics

Resources

License

Code of conduct

Contributing

Stars

Watchers

Forks

Sponsor this project

    Packages

    No packages published

    Contributors5


    [8]ページ先頭

    ©2009-2025 Movatter.jp