Skip to content
This repository has been archived by the owner on Feb 25, 2018. It is now read-only.
/ jquery-taphold Public archive

A jQuery event that's triggered when you click/tap and hold on an element for 1s.

License

Notifications You must be signed in to change notification settings

richadams/jquery-taphold

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 

Repository files navigation

A taphold event for jQuery.

Click/tap and hold for 1s (default) on an element to trigger a taphold event. If you release before the 1s then a normal click event is triggered instead. If you drag outside of the element while holding, then no event is triggered.

Usage:

$("#element").bind("taphold", function()
{
    // Actions
});

// or

$("#element").on("taphold", function()
{
    // Actions
});

You can combine the event with a click event but just also specifying a click event.

$("#element").on("taphold", function()
{
    // Actions for taphold
})
.on("click", function()
{
    // Actions for normal click
});

Or you can specify the click callback in the clickHandler option.

$("#element").on("taphold",
                 {clickHandler: function() { // Do this on click. }},
                 function() { // Do this on taphold. });

You can change the duration by passing a new value as an option.

$("#element").on("taphold", {duration: 2000}, function()
{
    // Actions will trigger after 2s instead of the default of 1s.
});

About

A jQuery event that's triggered when you click/tap and hold on an element for 1s.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published