ngx-visibility-change
v1.1.2
Published
This library uses the [InterceptionObserver API](https://developer.mozilla.org/es/docs/Web/API/Intersection_Observer_API) to get whenever a element in your Angular 2+ application is visible.
Downloads
11
Maintainers
Readme
ngx-visibility-change
This library uses the InterceptionObserver API to get whenever a element in your Angular 2+ application is visible.
It is highly inspired on ng-defer-load from Vamsi Vempati.
Demo
A demo can be found here on StackBlitz.
Installation
To install this library, run:
$ npm install ngx-visibility-change --save
Consuming your library
Once you have published your library to npm, you can import your library in any Angular application by running:
$ npm install ngx-visibility-change
and then from your Angular AppModule
:
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppComponent } from './app.component';
// Import your library
import { VisibilityChangeModule } from 'ngx-visibility-change';
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
// Specify your library as an import
VisibilityChangeModule
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
Once your library is imported, you can it inside your application like this:
<!-- You can now use your library component in app.component.html -->
<div (visibilityChange)="onVisibilityChange" [threshold]="1.0"></div>
Development
To generate all *.js
, *.d.ts
and *.metadata.json
files:
$ npm run build
To lint all *.ts
files:
$ npm run lint
License
MIT © Flexo Carpius