kamrify commited on
Commit
481fcd0
·
1 Parent(s): ca5785b

Fix#150 Touch devices result in driver blink

Browse files
Files changed (2) hide show
  1. package.json +1 -1
  2. src/index.js +8 -1
package.json CHANGED
@@ -1,6 +1,6 @@
1
  {
2
  "name": "driver.js",
3
- "version": "0.9.5",
4
  "description": "A light-weight, no-dependency, vanilla JavaScript library to drive the user's focus across the page",
5
  "main": "dist/driver.min.js",
6
  "types": "types/index.d.ts",
 
1
  {
2
  "name": "driver.js",
3
+ "version": "0.9.6",
4
  "description": "A light-weight, no-dependency, vanilla JavaScript library to drive the user's focus across the page",
5
  "main": "dist/driver.min.js",
6
  "types": "types/index.d.ts",
src/index.js CHANGED
@@ -91,7 +91,14 @@ export default class Driver {
91
  bind() {
92
  this.window.addEventListener('resize', this.onResize, false);
93
  this.window.addEventListener('keyup', this.onKeyUp, false);
94
- this.window.addEventListener('click', this.onClick, false);
 
 
 
 
 
 
 
95
  this.window.addEventListener('touchstart', this.onClick, false);
96
  }
97
 
 
91
  bind() {
92
  this.window.addEventListener('resize', this.onResize, false);
93
  this.window.addEventListener('keyup', this.onKeyUp, 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
+
102
  this.window.addEventListener('touchstart', this.onClick, false);
103
  }
104