1.1.1 • Published 6 years ago

detect-lingering v1.1.1

Weekly downloads
3
License
ISC
Repository
github
Last release
6 years ago

detect-lingering

Tiny utility for detecting when a user lingers, e.g. if they pause or slow down to look at something while scrolling

installation

npm install detect-lingering

usage

function onLinger () {
  console.log('user is lingering!')
}

var detector = createLingerDetector(onLinger, options)

el.onscroll = function () {
  // any actual calculations are deferred to a set interval
  // detector is very light method, and can be used in the scroll handler
  detector.update(el.scrollTop)
}

methods

  • update: call this every time your value changes, e.g. scrollTop. Detector uses this to detect lingering
  • stop: call this to stop any scheduled calculations

options

  • speed: 0.1 // speed below which we consider the user to be lingering
  • time: 400 // time the user has to linger for in order for the linger to count
  • timeout: 2000 // how long to keep monitoring for changes after the last change
  • interval: 50 // how frequently to monitor for changes

demo

npm run demo

run tests

npm test

js-standard-style

1.1.1

6 years ago

1.1.0

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago