Skip to content

Commit

Permalink
external: taphold.js update
Browse files Browse the repository at this point in the history
IITC-CE#70:
* update to last upstream: b59ed509a64080f4fd7c894fa7de83ceb92851e0
* upstream repo is archived now, so setup own fork: https://github.com/IITC-CE/jquery-taphold
* jQuery: fixed deprecated `bind`/`unbind` functions: a85050a7744d780809e8f007f6dc43065cdece9c
  • Loading branch information
johndoe committed Mar 15, 2019
1 parent b529475 commit cb74b46
Showing 1 changed file with 9 additions and 13 deletions.
22 changes: 9 additions & 13 deletions external/taphold.js
Expand Up @@ -19,7 +19,7 @@
// Merge the defaults and any user defined settings.
settings = jQuery.extend({}, defaults, event.data);

// If object also has click handler, store it and unbind. Taphold will trigger the
// If object also has click handler, store it and unbind (.off). Taphold will trigger the
// click itself, rather than normal propagation.
if (typeof $elem.data("events") != "undefined"
&& typeof $elem.data("events").click != "undefined")
Expand All @@ -31,7 +31,7 @@
{
var handler = $elem.data("events").click[c].handler
$elem.data("taphold_click_handler", handler);
$elem.unbind("click", handler);
$elem.off("click", handler);
break;
}
}
Expand Down Expand Up @@ -97,25 +97,21 @@

// Determine if touch events are supported.
var touchSupported = ("ontouchstart" in window) // Most browsers
|| ("onmsgesturechange" in window); // Mircosoft
|| ("onmsgesturechange" in window); // Microsoft

var taphold = $.event.special.taphold =
{
setup: function(data)
{
$(this).on((touchSupported ? "touchstart" : "mousedown"), data, startHandler)
.on((touchSupported ? "touchend" : "mouseup"), stopHandler)
.on((touchSupported ? "touchmove" : "mouseleave"), leaveHandler);
if(touchSupported)
$(this).on("touchcancel", leaveHandler);
$(this).on((touchSupported ? "touchstart" : "mousedown"), data, startHandler)
.on((touchSupported ? "touchend" : "mouseup"), stopHandler)
.on((touchSupported ? "touchmove touchcancel" : "mouseleave"), leaveHandler);
},
teardown: function(namespaces)
{
$(this).off((touchSupported ? "touchstart" : "mousedown"), startHandler)
.off((touchSupported ? "touchend" : "mouseup"), stopHandler)
.off((touchSupported ? "touchmove" : "mouseleave"), leaveHandler);
if(touchSupported)
$(this).off("touchcancel", leaveHandler);
$(this).off((touchSupported ? "touchstart" : "mousedown"), startHandler)
.off((touchSupported ? "touchend" : "mouseup"), stopHandler)
.off((touchSupported ? "touchmove touchcancel" : "mouseleave"), leaveHandler);
}
};
})(jQuery);

0 comments on commit cb74b46

Please sign in to comment.