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

Latest commit

 

History

History
39 lines (27 loc) · 687 Bytes

README.md

File metadata and controls

39 lines (27 loc) · 687 Bytes

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