diff --git a/package.json b/package.json index 6db117d..9c462bd 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/index.js b/src/index.js index 1dc1c37..a60925c 100644 --- a/src/index.js +++ b/src/index.js @@ -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); }