How to use:
1st: Make sure jQuery is included in your code
2nd:Include the script where in your code after jQuery has been included.
3rd: $('#pressable-element').setLongPress(function(){alert("LONG PRESSED")});
(function($){ | |
$.fn.setLongPress = function(longPress){ | |
var timer; | |
var doLongPress = function(){ | |
timer = setTimeout(longPress, .35 * 1000); | |
} | |
this.on("mousedown", doLongPress).on("mouseup mouseleave",function(){ | |
clearTimeout(timer); | |
}); | |
} | |
})(jQuery); |
DO WHATEVER YOU WANT TO PUBLIC LICENSE | |
Version 2, December 2004 | |
Copyright (C) 2016 Lincoln W Daniel <http://lincolnwdaniel.com> | |
Everyone is permitted to copy and distribute verbatim or modified | |
copies of this license document, and changing it is allowed as long | |
as the name is changed. |