Ngx observers is library to allow developer use Resize, Mutation and Intersection observer api like normal output events on some element.
| Angular version | Ngx observers version |
|---|---|
| 12, 13 | 0.0.0 - 1.x.x |
| 14 | 2.x.x |
npm install ngx-observers --save
then add NgxSimpleTextEditorModule into module imports
import {NgxObserversModule} from "ngx-observers";
@NgModule({
// ...
imports: [
// ...
NgxObserversModule,
// ...
],
// ...
})<div (obsResize)="resize($event)" [obsOptions]="{box: 'content-box'}" #elem="directive">...</div><div (obsMutation)="mutate($event)" [obsOptions]="{subtree: false}" #elem="directive">...</div><div (obsIntersection)="intersect($event)" [obsOptions]="{threshold: 0.5}" #elem="directive">...</div>You can access directive original observer object (e.g. this.obsResize.observer) using template variables (#elem="directive"):
@ViewChild('elem') obsResize: ResizeDirective | undefined;
@ViewChild('elem') obsMutation: MutationDirective | undefined;
@ViewChild('elem') obsIntersection: IntersectionDirective | undefined;See online
MIT