ngx-element-in-view
TypeScript icon, indicating that this package has built-in type declarations

0.0.6Β β€’Β PublicΒ β€’Β Published

ngx-in-view

πŸ” Angular directive to detect when an element enters the viewport using IntersectionObserver. Add animation classes or trigger callbacks with ease.

npm downloads license


✨ Features

  • πŸ” Automatically detect when an element comes into view
  • 🎨 Add CSS animation classes
  • πŸ”” Trigger callbacks via (inView) event
  • βš™οΈ Configurable threshold and trigger behavior
  • 🧩 Works great with lazy-loading and animation libraries like Animate.css or GSAP

πŸ“¦ Installation

npm install ngx-in-view

## 🧰 Parameters

| Parameter         | Type                    | Default  | Description                                                                 |
|-------------------|-------------------------|----------|-----------------------------------------------------------------------------|
| `ngxElementInView`       | `string`                | `''`     | (Optional) Space-separated CSS classes to apply when element is in view     |
| `threshold`       | `number`                | `0.1`    | (Optional) Visibility ratio (0 to 1) required to trigger the directive       |
| `triggerOnce`     | `boolean`               | `true`   | (Optional) If true, the directive triggers only once                        |
| `visibilityBeforeInView`     | `boolean`               | `true`   | (Optional) If false, the element will display only once in view                       |
| `(inView)`        | `EventEmitter<void>`    | β€”        | Emits when the element becomes visible in the viewport                      |


## Example

<div
  [ngxElementInView]="'fade-in bounce'"
  [threshold]="0.3"
  [triggerOnce]="true"
>
  This will animate when it appears in the viewport!
</div>

Package Sidebar

Install

npm i ngx-element-in-view

Weekly Downloads

10

Version

0.0.6

License

MIT

Unpacked Size

13.3 kB

Total Files

8

Last publish

Collaborators

  • shaileshrv