RubickMischief / jquery-taphold

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

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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.

License:Other


Languages

Language:JavaScript 60.2%Language:HTML 39.8%