Fix#150 Touch devices result in driver blink

This commit is contained in:
Kamran Ahmed
2019-05-07 14:55:18 +04:00
parent ca5785bad8
commit 481fcd067b
2 changed files with 9 additions and 2 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "driver.js",
"version": "0.9.5",
"version": "0.9.6",
"description": "A light-weight, no-dependency, vanilla JavaScript library to drive the user's focus across the page",
"main": "dist/driver.min.js",
"types": "types/index.d.ts",
+8 -1
View File
@@ -91,7 +91,14 @@ export default class Driver {
bind() {
this.window.addEventListener('resize', this.onResize, false);
this.window.addEventListener('keyup', this.onKeyUp, false);
this.window.addEventListener('click', this.onClick, false);
// Binding both touch and click results in popup getting shown and then immediately get hidden.
// Adding the check to not bind the click event if the touch is supported i.e. on mobile devices
// Issue: https://github.com/kamranahmedse/driver.js/issues/150
if (!('ontouchstart' in document.documentElement)) {
this.window.addEventListener('click', this.onClick, false);
}
this.window.addEventListener('touchstart', this.onClick, false);
}