0.2.3 • Published 7 years ago

angular-inviewport v0.2.3

Weekly downloads
6
License
MIT
Repository
-
Last release
7 years ago

Angular InViewport

Build Status Coverage Status

A simple lightweight library for Angular (2+) with no external dependencies that detects when an element is within the browser viewport and adds a in-viewport or not-in-viewport class to the element.

This is a simple library for Angular, implemented in the Angular Package Format v4.0.

Install

npm i angular-inviewport --save

app.module.ts

import { InViewportModule } from 'angular-inviewport';

@NgModule({
  imports: [
    /** other imports **/
    InViewportModule,
    /** other imports **/
  ],
  /** other ngModule code **/
})
export class AppModule { }

Example

Just using classes

<p class="foo" inViewport>Amet tempor excepteur occaecat nulla.</p>
.foo {
  transition: transform .35s ease-out;
}

.foo.not-in-viewport {
  transform: translateY(-30px);
}

.foo.in-viewport {
  transform: translateY(0);
}

Using events

<p class="foo" inViewport (onInViewportChange)="onInViewportChange($event)">
  Amet tempor excepteur occaecat nulla.
</p>
export class AppComponent {
  highlight = false;

  onInViewportChange(inViewport: boolean) {
    this.highlight = inViewport;
  }
}
.highlight {
  background-color: yellow;
}

Specify debounce time (default: 100ms)

<p class="foo" inViewport [debounce]="500">
  Amet tempor excepteur occaecat nulla.
</p>
0.2.3

7 years ago

0.2.2

7 years ago

0.2.1

7 years ago

0.2.0

7 years ago

0.1.3

7 years ago

0.1.2

7 years ago

0.1.1

7 years ago

0.1.0

7 years ago

0.0.2

7 years ago

0.0.1

7 years ago