Skip to content

derrickreimer/jquery-longclick

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

Longclick

A jQuery plugin for long button clicks. Extracted from Codetree, inspired by UI patterns found in Zapier.

Usage

Some buttons lead to particularly destructive actions (like the classic "Delete" button). One common way to help users avoid accidentally perform a destructive action is to prompt them with an "Are you sure?" dialog box.

This plugin helps you employ an alternative strategy: the long button click. When a user pushes down on a long click button, this plugin can automatically swap out the button text for something like "Hold to delete...". If the user continues to hold down the button for a set duration of time (default of 1 second), then a longclick event will be fired.

$("#delete-button").longclick({
  holdText: "Hold to delete...",  // default: "Hold..."
  heldText: "Deleting...",        // default: null (will revert back to original text)
  duration: 1000                  // default: 1000
}).on("longclick", function() {
  // do something
})

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

About

A jQuery plugin for facilitating long button clicks

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published