Created
September 3, 2020 14:02
-
-
Save acenturyandabit/026d0d7c2035a34956af2c43f7269f7b to your computer and use it in GitHub Desktop.
in case double click doesnt work for some reason
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(() => { | |
Element.prototype.pre_doubleclick_addEventListener = Element.prototype.addEventListener; | |
Element.prototype.addEventListener = function (ename, fn) { | |
let clickCount = 0; | |
let singleClickTimer = 0; | |
if (ename == "dblclick") { | |
this.pre_doubleclick_addEventListener("click", (e) => { | |
clickCount++; | |
if (clickCount == 1) { | |
singleClickTimer = setTimeout(function () { | |
clickCount = 0; | |
}, 400); | |
} else if (clickCount == 2) { | |
clearTimeout(singleClickTimer); | |
clickCount = 0; | |
fn(e); | |
} | |
}) | |
} else { | |
this.pre_doubleclick_addEventListener(...arguments); | |
} | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment