@modernice/appeared
TypeScript icon, indicating that this package has built-in type declarations

0.2.1 • Public • Published

appeared.js

Simple tracking of DOM elements scrolling in and out of the view.

Install

Package Manager

yarn add @modernice/appeared // npm install @modernice/appeared --save

CDN

Modern version

<script src="https://unpkg.com/@modernice/appeared"></script>

Use

import appeared from '@modernice/appeared'

const stop = appeared('#trigger', {
  multiple: true,

  appear: (el: Element, count: number) => {
    console.log(`element appeared ${count} times.`)
  },

  disappear: (el: Element, count: number) => {
    console.log(`element disappeared ${count} times.`)
  }
})

// disconnect the underlying IntersectionObserver
stop()

Package Sidebar

Install

npm i @modernice/appeared

Weekly Downloads

1

Version

0.2.1

License

MIT

Unpacked Size

8.53 kB

Total Files

9

Last publish

Collaborators

  • bono