bloody-scroll-direction

gets scroll direction and notifies on change

Usage no npm install needed!

<script type="module">
  import bloodyScrollDirection from 'https://cdn.skypack.dev/bloody-scroll-direction';
</script>

README

scroll-direction

browser support

install

$ npm install bloody-scroll-direction

require

var scrollDir = require("bloody-scroll-direction")

api

scrollDir.create() > s

creates a scrollDir instance and starts listening to the scroll event.

scrollDir.destroy()

stops listening to the scroll event.

scrollDir.on("change", callback)

let callback be notified when the scroll direction changes.

a data object is passed to callback, containing to properties :

offset

scroll value

direction

  • 1 if the scroll goes forward
  • -1 if the scroll goes backward