npm.io
0.0.2 • Published 8 years ago

ngx-in-viewport

Licence
MIT
Version
0.0.2
Deps
1
Size
30 kB
Vulns
0
Weekly
0

ngx-in-viewport

npm version

A simple Angular Directive to easily determine if a element in in the viewport.

Demo

Installation

To install this library, run:

npm install ngx-in-viewport --save

and then from your Angular AppModule:

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { NgxInViewportModule } from 'ngx-in-viewport';

import { AppComponent } from './app.component';

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,
    NgxInViewportModule
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }

Component

Once the library is imported, you can use the ngx-debounce-click directive.

import { Component, OnInit } from '@angular/core';
import { FormBuilder, FormGroup } from '@angular/forms';

@Component({
  selector: 'app-root',
  template: `
  <div ngxInViewport (inViewport)="log($event)">
    Hello World!
  </div>
  `
})
export class AppComponent {
  log(event) {
    console.log(event);
  }
}

License

MIT Cory Rylan