This package has been deprecated

Author message:

This project is deprecated. Consider using the Intersection Observer API instead.

hydrophone

0.1.1 • Public • Published

Hydrophone

Build Status Test Coverage Dependency Status devDependency Status

Track when a DOM node enters or leaves the screen.

Get Started

npm install hydrophone

API

add(node, events)

Start tracking a DOM node.

  • node: DOM node object. (Node)
  • events: Object, containing zero or more of the following properties:
    • enters: Function called when the element enters the viewport. (Function)
    • leaves: Function called when the element exits the viewport. (Function)

remove(node)

Stop tracking a DOM node.

  • node: DOM node object. (Node)

Usage

import { add, remove } from 'hydrophone'
 
var node = document.getElementById('node')
add(node, {
  enters: () => {
    remove(node) // optional
  }
})
 

License

See the License file.

Package Sidebar

Install

npm i hydrophone

Weekly Downloads

2

Version

0.1.1

License

MIT

Last publish

Collaborators

  • grindcode