ngx-visibility-change
TypeScript icon, indicating that this package has built-in type declarations

1.1.2 • Public • Published

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

Package Sidebar

Install

npm i ngx-visibility-change

Weekly Downloads

3

Version

1.1.2

License

MIT

Unpacked Size

11.3 kB

Total Files

9

Last publish

Collaborators

  • flexocarpius