Skip to content

Commit 481fcd0

Browse files
committed
Fix#150 Touch devices result in driver blink
1 parent ca5785b commit 481fcd0

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "driver.js",
3-
"version": "0.9.5",
3+
"version": "0.9.6",
44
"description": "A light-weight, no-dependency, vanilla JavaScript library to drive the user's focus across the page",
55
"main": "dist/driver.min.js",
66
"types": "types/index.d.ts",

src/index.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,14 @@ export default class Driver {
9191
bind() {
9292
this.window.addEventListener('resize', this.onResize, false);
9393
this.window.addEventListener('keyup', this.onKeyUp, false);
94-
this.window.addEventListener('click', this.onClick, false);
94+
95+
// Binding both touch and click results in popup getting shown and then immediately get hidden.
96+
// Adding the check to not bind the click event if the touch is supported i.e. on mobile devices
97+
// Issue: https://github.com/kamranahmedse/driver.js/issues/150
98+
if (!('ontouchstart' in document.documentElement)) {
99+
this.window.addEventListener('click', this.onClick, false);
100+
}
101+
95102
this.window.addEventListener('touchstart', this.onClick, false);
96103
}
97104

0 commit comments

Comments
 (0)