This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Long click in Custom JS
#1
Hello,

what is appropriate way to add longclick event on object which by default has only click event. I don't to delete this click event, I want only additionally add longclick. Now I've tried something like below:

Code:
function onLongClick(selector, timeout, callback) {
   let touchstart, touchend;
   selector.on('touchstart mousedown', function(e) {
     touchstart = e.timeStamp;
   })

   selector.on('touchend mouseup', function(e) {
     touchend = e.timeStamp;
     if (touchend - touchstart > timeout) callback();
   })
 }


But it is triggered with also default click, but I want to cancel click event when longpress is detected. Maybe admin have some adviceWink
Reply


Messages In This Thread
Long click in Custom JS - by buuuudzik - 06.02.2018, 14:13
RE: Long click in Custom JS - by Daniel - 06.02.2018, 15:59
RE: Long click in Custom JS - by buuuudzik - 06.02.2018, 16:11
RE: Long click in Custom JS - by buuuudzik - 06.02.2018, 20:26
RE: Long click in Custom JS - by admin - 08.02.2018, 09:32

Forum Jump: