0.4.3 • Published 6 years ago

appeared v0.4.3

Weekly downloads
2
License
MIT
Repository
github
Last release
6 years ago

appeared.js

Track DOM elements as they scroll into and out of view.

Installation

via npm

npm install appeared

via yarn

yarn add appeared

Usage

Call appeared() with a config object.

Configuration

The config object can have the following parameters:

  • elements HTMLElement[]|HTMLElement|HTMLCollection|NodeList|string[]|string or a function returning one of the types.
  • appear function to call when an element scrolls into view.
  • disappear function to call when an element scolls out of view.
  • multiple boolean that indicates if the (dis)appear callbacks should be called successively. Defaults to false.

The Watcher instance

The appeared() function returns either a single or an array of Watcher instances.

Watcher methods:

  • detroy removes the event listeners from the window and clears the watcher

Example

import appeared from 'appeared'

appeared({
    elements: ['.element', '#special-element'],
    multiple: true,
    appear: (element, count) => {
        // Element scrolled into view
    },
    disappear: (element, count) => {
        // Element scrolled out of view
    }
})
0.4.3

6 years ago

0.4.2

6 years ago

0.4.1

6 years ago

0.4.0

6 years ago

0.3.0

6 years ago

0.2.7

6 years ago

0.2.6

6 years ago

0.2.5

6 years ago

0.2.4

6 years ago

0.2.3

6 years ago

0.2.2

6 years ago

0.2.1

6 years ago

0.2.0

6 years ago

0.1.2

6 years ago

0.1.1

6 years ago

0.1.0

6 years ago