0

how not to follow link when double click

I have a card follow a single page, like a href="./single-page.html". on click, it should follow the single page and it does, for double click I want it to stay on page. on double click eventlistner ,all e.preventDefault() e.stopPropagation() e.stopImmediatePropagation() and return not work

27th Jun 2020, 2:39 PM
anjit pariyar
anjit pariyar - avatar
4 Respuestas
+ 1
Looks like a tough one, I found this on SO, but I haven't tested it for validity, maybe you can check for yourself https://stackoverflow.com/questions/880608/prevent-click-event-from-firing-when-dblclick-event-fires/29993141
27th Jun 2020, 4:18 PM
Ipang
+ 1
Ipang I tried but not helping, here what I notice when I double click .1 first click eventhandling fired, 2 second dblclick handle fired and again 3 third click event fired. I also try unbind but at last it goes to click event ...
27th Jun 2020, 7:25 PM
anjit pariyar
anjit pariyar - avatar
+ 1
wait.. its working but im not sure if its a clean code. here is code let dbClick=1; $node.on("click", function (e) { if (e.detail === 1) { if(dbClick===0){ e.preventDefault() console.log('stop') dbClick=0 } else{ dbClick++; } console.log(1) } else if (e.detail === 2) { e.preventDefault() dbClick=0 console.log(2) setTimeout(()=>{ dbClick++; }, 300) } });
27th Jun 2020, 7:37 PM
anjit pariyar
anjit pariyar - avatar
0
If there is no double click event listener. A double click will count as a click(or two)
27th Jun 2020, 4:15 PM
Ore
Ore - avatar