Skip to content
This repository has been archived by the owner on Jan 11, 2021. It is now read-only.
/ appeared.js Public archive

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

License

Notifications You must be signed in to change notification settings

modernice/appeared.js

Repository files navigation

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()

About

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

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published