scrollin

A leak free performance focused scroll util

MIT License

Downloads
42
Stars
122
Committers
7

Scrollin

Install

Use

Scrollin.track(document.querySelector('#hi'), () => alert('hi!'))

Options

You can specify optional offset params to control when an elements is considered in the "viewport".

Scrollin.track(document.querySelector('#hi'), () => alert('hi!'), {
  top: 10,
  right: -10,
  bottom: 10,
  left: 10
})

API

  • Scrollin.track(document.querySelector('#hi'), () => alert('hi!'))
  • Scrollin.track(document.querySelectorAll('.hi'), () => alert('hi!'))
  • Scrollin.untrackAll()
  • Scrollin.untrack(document.querySelector('#hi'))
  • Scrollin.checkForVisibleElements()
  • Scrollin.getTracking()

Dev

  • npm i
  • npm run dev

Building

  • npm run compile

Polyfill Caveats

  • You may need to polyfill window.requestAnimationFrame
  • You may need to polyfill Array.prototype.splice
  • You may need to polyfill Array.prototype.some

📜