From 6ef2352020bd9a993250d9c62bb7c1502e03379b Mon Sep 17 00:00:00 2001 From: vas3k Date: Wed, 22 Apr 2020 17:31:20 +0200 Subject: [PATCH] Remove ontouch events (buggy on iphones) --- static/js/main.js | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/static/js/main.js b/static/js/main.js index 3a43ed0..c4effae 100644 --- a/static/js/main.js +++ b/static/js/main.js @@ -116,24 +116,20 @@ function showTooltipOnClickOnMobile() { } if (isMobile()) { - function mobileClickHandler(e) { - if (e.cancelable) { - e.preventDefault(); // do not open the link - e.stopImmediatePropagation(); - } - - let tooltip = e.target.parentElement.querySelector(".article-tooltip"); - if (tooltip !== null) { - tooltip.style.visibility = "visible"; - } - return false; - } - let articleLinks = document.querySelectorAll(".article-link"); for (let i = 0; i < articleLinks.length; i++) { - articleLinks[i].addEventListener("click", mobileClickHandler); - articleLinks[i].addEventListener("touchstart", mobileClickHandler); - articleLinks[i].addEventListener("touchend", (e) => false); + articleLinks[i].addEventListener("click", function(e) { + if (e.cancelable) { + e.preventDefault(); // do not open the link + e.stopImmediatePropagation(); + } + + let tooltip = e.target.parentElement.querySelector(".article-tooltip"); + if (tooltip !== null) { + tooltip.style.visibility = "visible"; + } + return false; + }); } } }