Skip to content

Repeated events for pressing and holding down DOM elements.

License

Notifications You must be signed in to change notification settings

mathiasvr/on-hold

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

on-hold npm dependencies license

Repeated events for pressing and holding down DOM elements.

View example on RequireBin

install

$ npm install on-hold

example

Holding down the button will call the function repeatedly:

var onHold = require('on-hold')

var btn = document.createElement('button')
btn.textContent = 'Press and Hold'

onHold(btn, function () {
  console.log('action fired')
})

document.body.appendChild(btn)

api

onHold(element [, { wait: 500, interval: 200 }], action)

element

DOM element to attach events to.

options

  • wait: initial time in ms to hold down before repeating action.
  • interval: interval in ms between repeated actions after inital hold down.

action

Event handler function.

license

MIT

About

Repeated events for pressing and holding down DOM elements.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published