From 8288e530776b85a5822c5d317962f62b5a808bf7 Mon Sep 17 00:00:00 2001 From: Ivan Wills Date: Mon, 9 Apr 2018 08:57:43 +1000 Subject: [PATCH 01/13] Adding listening to click for when pointer is available as jaws on IE appears to send click events --- src/ractive-events-tap.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/ractive-events-tap.js b/src/ractive-events-tap.js index 2e47b1e..e373872 100644 --- a/src/ractive-events-tap.js +++ b/src/ractive-events-tap.js @@ -95,10 +95,12 @@ TapHandler.prototype = { this.node.addEventListener( 'pointerup', handleMouseup, false ); document.addEventListener( 'pointermove', handleMousemove, false ); document.addEventListener( 'pointercancel', cancel, false ); + this.node.addEventListener( 'click', handleMouseup, false ); } else if ( window.navigator.msPointerEnabled ) { this.node.addEventListener( 'MSPointerUp', handleMouseup, false ); document.addEventListener( 'MSPointerMove', handleMousemove, false ); document.addEventListener( 'MSPointerCancel', cancel, false ); + this.node.addEventListener( 'click', handleMouseup, false ); } else { this.node.addEventListener( 'click', handleMouseup, false ); document.addEventListener( 'mousemove', handleMousemove, false ); From 3e7d15c8b57725480cfe07db935782199b95b0f6 Mon Sep 17 00:00:00 2001 From: Ivan Wills Date: Mon, 9 Apr 2018 08:58:25 +1000 Subject: [PATCH 02/13] Debugging events --- src/ractive-events-tap.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/ractive-events-tap.js b/src/ractive-events-tap.js index e373872..191bc87 100644 --- a/src/ractive-events-tap.js +++ b/src/ractive-events-tap.js @@ -92,16 +92,19 @@ TapHandler.prototype = { }; if ( window.navigator.pointerEnabled ) { + console.log('ractive-events-tap pointerEnabled'); this.node.addEventListener( 'pointerup', handleMouseup, false ); document.addEventListener( 'pointermove', handleMousemove, false ); document.addEventListener( 'pointercancel', cancel, false ); this.node.addEventListener( 'click', handleMouseup, false ); } else if ( window.navigator.msPointerEnabled ) { + console.log('ractive-events-tap msPointerEnabled'); this.node.addEventListener( 'MSPointerUp', handleMouseup, false ); document.addEventListener( 'MSPointerMove', handleMousemove, false ); document.addEventListener( 'MSPointerCancel', cancel, false ); this.node.addEventListener( 'click', handleMouseup, false ); } else { + console.log('ractive-events-tap pointerless'); this.node.addEventListener( 'click', handleMouseup, false ); document.addEventListener( 'mousemove', handleMousemove, false ); } From bc184ccd5dd34e364c34f29b8b11bcd27a03dbf1 Mon Sep 17 00:00:00 2001 From: Ivan Wills Date: Mon, 9 Apr 2018 08:58:56 +1000 Subject: [PATCH 03/13] Built code --- dist/ractive-events-tap.es.js | 5 + dist/ractive-events-tap.umd.js | 337 +++++++++++++++++---------------- 2 files changed, 176 insertions(+), 166 deletions(-) diff --git a/dist/ractive-events-tap.es.js b/dist/ractive-events-tap.es.js index cd1ce9f..0e46743 100644 --- a/dist/ractive-events-tap.es.js +++ b/dist/ractive-events-tap.es.js @@ -94,14 +94,19 @@ TapHandler.prototype = { }; if ( window.navigator.pointerEnabled ) { + console.log('ractive-events-tap pointerEnabled'); this.node.addEventListener( 'pointerup', handleMouseup, false ); document.addEventListener( 'pointermove', handleMousemove, false ); document.addEventListener( 'pointercancel', cancel, false ); + this.node.addEventListener( 'click', handleMouseup, false ); } else if ( window.navigator.msPointerEnabled ) { + console.log('ractive-events-tap msPointerEnabled'); this.node.addEventListener( 'MSPointerUp', handleMouseup, false ); document.addEventListener( 'MSPointerMove', handleMousemove, false ); document.addEventListener( 'MSPointerCancel', cancel, false ); + this.node.addEventListener( 'click', handleMouseup, false ); } else { + console.log('ractive-events-tap pointerless'); this.node.addEventListener( 'click', handleMouseup, false ); document.addEventListener( 'mousemove', handleMousemove, false ); } diff --git a/dist/ractive-events-tap.umd.js b/dist/ractive-events-tap.umd.js index d380f38..a9caa3c 100644 --- a/dist/ractive-events-tap.umd.js +++ b/dist/ractive-events-tap.umd.js @@ -2,210 +2,215 @@ typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : typeof define === 'function' && define.amd ? define(factory) : (global.Ractive = global.Ractive || {}, global.Ractive.events = global.Ractive.events || {}, global.Ractive.events.tap = factory()); -}(this, function () { 'use strict'; +}(this, (function () { 'use strict'; - var DISTANCE_THRESHOLD = 5; // maximum pixels pointer can move before cancel - var TIME_THRESHOLD = 400; // maximum milliseconds between down and up before cancel +var DISTANCE_THRESHOLD = 5; // maximum pixels pointer can move before cancel +var TIME_THRESHOLD = 400; // maximum milliseconds between down and up before cancel - function tap ( node, callback ) { - return new TapHandler( node, callback ); - } +function tap ( node, callback ) { + return new TapHandler( node, callback ); +} - function TapHandler ( node, callback ) { - this.node = node; - this.callback = callback; +function TapHandler ( node, callback ) { + this.node = node; + this.callback = callback; - this.preventMousedownEvents = false; + this.preventMousedownEvents = false; - this.bind( node ); - } + this.bind( node ); +} - TapHandler.prototype = { - bind: function bind ( node ) { - // listen for mouse/pointer events... - if (window.navigator.pointerEnabled) { - node.addEventListener( 'pointerdown', handleMousedown, false ); - } else if (window.navigator.msPointerEnabled) { - node.addEventListener( 'MSPointerDown', handleMousedown, false ); - } else { - node.addEventListener( 'mousedown', handleMousedown, false ); - - // ...and touch events - node.addEventListener( 'touchstart', handleTouchstart, false ); - } +TapHandler.prototype = { + bind: function bind ( node ) { + // listen for mouse/pointer events... + if (window.navigator.pointerEnabled) { + node.addEventListener( 'pointerdown', handleMousedown, false ); + } else if (window.navigator.msPointerEnabled) { + node.addEventListener( 'MSPointerDown', handleMousedown, false ); + } else { + node.addEventListener( 'mousedown', handleMousedown, false ); - // native buttons, and elements, should fire a tap event - // when the space key is pressed - if ( node.tagName === 'BUTTON' || node.type === 'button' ) { - node.addEventListener( 'focus', handleFocus, false ); - } + // ...and touch events + node.addEventListener( 'touchstart', handleTouchstart, false ); + } + + // native buttons, and elements, should fire a tap event + // when the space key is pressed + if ( node.tagName === 'BUTTON' || node.type === 'button' ) { + node.addEventListener( 'focus', handleFocus, false ); + } + + node.__tap_handler__ = this; + }, + + fire: function fire ( event, x, y ) { + this.callback({ + node: this.node, + original: event, + x: x, + y: y + }); + }, - node.__tap_handler__ = this; - }, + mousedown: function mousedown ( event ) { + var this$1 = this; - fire: function fire ( event, x, y ) { - this.callback({ - node: this.node, - original: event, - x: x, - y: y - }); - }, + if ( this.preventMousedownEvents ) { + return; + } + + if ( event.which !== undefined && event.which !== 1 ) { + return; + } - mousedown: function mousedown ( event ) { - var this$1 = this; + var x = event.clientX; + var y = event.clientY; - if ( this.preventMousedownEvents ) { + // This will be null for mouse events. + var pointerId = event.pointerId; + + var handleMouseup = function (event) { + if ( event.pointerId != pointerId ) { return; } - if ( event.which !== undefined && event.which !== 1 ) { + this$1.fire( event, x, y ); + cancel(); + }; + + var handleMousemove = function (event) { + if ( event.pointerId != pointerId ) { return; } - var x = event.clientX; - var y = event.clientY; + if ( ( Math.abs( event.clientX - x ) >= DISTANCE_THRESHOLD ) || ( Math.abs( event.clientY - y ) >= DISTANCE_THRESHOLD ) ) { + cancel(); + } + }; + + var cancel = function () { + this$1.node.removeEventListener( 'MSPointerUp', handleMouseup, false ); + document.removeEventListener( 'MSPointerMove', handleMousemove, false ); + document.removeEventListener( 'MSPointerCancel', cancel, false ); + this$1.node.removeEventListener( 'pointerup', handleMouseup, false ); + document.removeEventListener( 'pointermove', handleMousemove, false ); + document.removeEventListener( 'pointercancel', cancel, false ); + this$1.node.removeEventListener( 'click', handleMouseup, false ); + document.removeEventListener( 'mousemove', handleMousemove, false ); + }; + + if ( window.navigator.pointerEnabled ) { + console.log('ractive-events-tap pointerEnabled'); + this.node.addEventListener( 'pointerup', handleMouseup, false ); + document.addEventListener( 'pointermove', handleMousemove, false ); + document.addEventListener( 'pointercancel', cancel, false ); + this.node.addEventListener( 'click', handleMouseup, false ); + } else if ( window.navigator.msPointerEnabled ) { + console.log('ractive-events-tap msPointerEnabled'); + this.node.addEventListener( 'MSPointerUp', handleMouseup, false ); + document.addEventListener( 'MSPointerMove', handleMousemove, false ); + document.addEventListener( 'MSPointerCancel', cancel, false ); + this.node.addEventListener( 'click', handleMouseup, false ); + } else { + console.log('ractive-events-tap pointerless'); + this.node.addEventListener( 'click', handleMouseup, false ); + document.addEventListener( 'mousemove', handleMousemove, false ); + } + + setTimeout( cancel, TIME_THRESHOLD ); + }, - // This will be null for mouse events. - var pointerId = event.pointerId; + touchdown: function touchdown ( event ) { + var this$1 = this; - var handleMouseup = function (event) { - if ( event.pointerId != pointerId ) { - return; - } + var touch = event.touches[0]; - this$1.fire( event, x, y ); + var x = touch.clientX; + var y = touch.clientY; + + var finger = touch.identifier; + + var handleTouchup = function (event) { + var touch = event.changedTouches[0]; + + if ( touch.identifier !== finger ) { cancel(); - }; - - var handleMousemove = function (event) { - if ( event.pointerId != pointerId ) { - return; - } - - if ( ( Math.abs( event.clientX - x ) >= DISTANCE_THRESHOLD ) || ( Math.abs( event.clientY - y ) >= DISTANCE_THRESHOLD ) ) { - cancel(); - } - }; - - var cancel = function () { - this$1.node.removeEventListener( 'MSPointerUp', handleMouseup, false ); - document.removeEventListener( 'MSPointerMove', handleMousemove, false ); - document.removeEventListener( 'MSPointerCancel', cancel, false ); - this$1.node.removeEventListener( 'pointerup', handleMouseup, false ); - document.removeEventListener( 'pointermove', handleMousemove, false ); - document.removeEventListener( 'pointercancel', cancel, false ); - this$1.node.removeEventListener( 'click', handleMouseup, false ); - document.removeEventListener( 'mousemove', handleMousemove, false ); - }; - - if ( window.navigator.pointerEnabled ) { - this.node.addEventListener( 'pointerup', handleMouseup, false ); - document.addEventListener( 'pointermove', handleMousemove, false ); - document.addEventListener( 'pointercancel', cancel, false ); - } else if ( window.navigator.msPointerEnabled ) { - this.node.addEventListener( 'MSPointerUp', handleMouseup, false ); - document.addEventListener( 'MSPointerMove', handleMousemove, false ); - document.addEventListener( 'MSPointerCancel', cancel, false ); - } else { - this.node.addEventListener( 'click', handleMouseup, false ); - document.addEventListener( 'mousemove', handleMousemove, false ); + return; } - setTimeout( cancel, TIME_THRESHOLD ); - }, + event.preventDefault(); // prevent compatibility mouse event - touchdown: function touchdown ( event ) { - var this$1 = this; + // for the benefit of mobile Firefox and old Android browsers, we need this absurd hack. + this$1.preventMousedownEvents = true; + clearTimeout( this$1.preventMousedownTimeout ); - var touch = event.touches[0]; + this$1.preventMousedownTimeout = setTimeout( function () { + this$1.preventMousedownEvents = false; + }, 400 ); - var x = touch.clientX; - var y = touch.clientY; + this$1.fire( event, x, y ); + cancel(); + }; - var finger = touch.identifier; - - var handleTouchup = function (event) { - var touch = event.changedTouches[0]; + var handleTouchmove = function (event) { + if ( event.touches.length !== 1 || event.touches[0].identifier !== finger ) { + cancel(); + } - if ( touch.identifier !== finger ) { - cancel(); - return; - } + var touch = event.touches[0]; + if ( ( Math.abs( touch.clientX - x ) >= DISTANCE_THRESHOLD ) || ( Math.abs( touch.clientY - y ) >= DISTANCE_THRESHOLD ) ) { + cancel(); + } + }; - event.preventDefault(); // prevent compatibility mouse event + var cancel = function () { + this$1.node.removeEventListener( 'touchend', handleTouchup, false ); + window.removeEventListener( 'touchmove', handleTouchmove, false ); + window.removeEventListener( 'touchcancel', cancel, false ); + }; - // for the benefit of mobile Firefox and old Android browsers, we need this absurd hack. - this$1.preventMousedownEvents = true; - clearTimeout( this$1.preventMousedownTimeout ); + this.node.addEventListener( 'touchend', handleTouchup, false ); + window.addEventListener( 'touchmove', handleTouchmove, false ); + window.addEventListener( 'touchcancel', cancel, false ); - this$1.preventMousedownTimeout = setTimeout( function () { - this$1.preventMousedownEvents = false; - }, 400 ); + setTimeout( cancel, TIME_THRESHOLD ); + }, - this$1.fire( event, x, y ); - cancel(); - }; - - var handleTouchmove = function (event) { - if ( event.touches.length !== 1 || event.touches[0].identifier !== finger ) { - cancel(); - } - - var touch = event.touches[0]; - if ( ( Math.abs( touch.clientX - x ) >= DISTANCE_THRESHOLD ) || ( Math.abs( touch.clientY - y ) >= DISTANCE_THRESHOLD ) ) { - cancel(); - } - }; - - var cancel = function () { - this$1.node.removeEventListener( 'touchend', handleTouchup, false ); - window.removeEventListener( 'touchmove', handleTouchmove, false ); - window.removeEventListener( 'touchcancel', cancel, false ); - }; - - this.node.addEventListener( 'touchend', handleTouchup, false ); - window.addEventListener( 'touchmove', handleTouchmove, false ); - window.addEventListener( 'touchcancel', cancel, false ); - - setTimeout( cancel, TIME_THRESHOLD ); - }, - - teardown: function teardown () { - var node = this.node; - - node.removeEventListener( 'pointerdown', handleMousedown, false ); - node.removeEventListener( 'MSPointerDown', handleMousedown, false ); - node.removeEventListener( 'mousedown', handleMousedown, false ); - node.removeEventListener( 'touchstart', handleTouchstart, false ); - node.removeEventListener( 'focus', handleFocus, false ); - } - }; + teardown: function teardown () { + var node = this.node; - function handleMousedown ( event ) { - this.__tap_handler__.mousedown( event ); + node.removeEventListener( 'pointerdown', handleMousedown, false ); + node.removeEventListener( 'MSPointerDown', handleMousedown, false ); + node.removeEventListener( 'mousedown', handleMousedown, false ); + node.removeEventListener( 'touchstart', handleTouchstart, false ); + node.removeEventListener( 'focus', handleFocus, false ); } +}; - function handleTouchstart ( event ) { - this.__tap_handler__.touchdown( event ); - } +function handleMousedown ( event ) { + this.__tap_handler__.mousedown( event ); +} - function handleFocus () { - this.addEventListener( 'keydown', handleKeydown, false ); - this.addEventListener( 'blur', handleBlur, false ); - } +function handleTouchstart ( event ) { + this.__tap_handler__.touchdown( event ); +} - function handleBlur () { - this.removeEventListener( 'keydown', handleKeydown, false ); - this.removeEventListener( 'blur', handleBlur, false ); - } +function handleFocus () { + this.addEventListener( 'keydown', handleKeydown, false ); + this.addEventListener( 'blur', handleBlur, false ); +} - function handleKeydown ( event ) { - if ( event.which === 32 ) { // space key - this.__tap_handler__.fire(); - } +function handleBlur () { + this.removeEventListener( 'keydown', handleKeydown, false ); + this.removeEventListener( 'blur', handleBlur, false ); +} + +function handleKeydown ( event ) { + if ( event.which === 32 ) { // space key + this.__tap_handler__.fire(); } +} - return tap; +return tap; -})); \ No newline at end of file +}))); \ No newline at end of file From 68795adaed1c7e5918be53dc4a642dc9799246d9 Mon Sep 17 00:00:00 2001 From: Ivan Wills Date: Mon, 16 Apr 2018 12:13:59 +1000 Subject: [PATCH 04/13] Always listening to click events and supporting enter keys for tap --- src/ractive-events-tap.js | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/ractive-events-tap.js b/src/ractive-events-tap.js index 191bc87..5d49b07 100644 --- a/src/ractive-events-tap.js +++ b/src/ractive-events-tap.js @@ -96,18 +96,15 @@ TapHandler.prototype = { this.node.addEventListener( 'pointerup', handleMouseup, false ); document.addEventListener( 'pointermove', handleMousemove, false ); document.addEventListener( 'pointercancel', cancel, false ); - this.node.addEventListener( 'click', handleMouseup, false ); } else if ( window.navigator.msPointerEnabled ) { console.log('ractive-events-tap msPointerEnabled'); this.node.addEventListener( 'MSPointerUp', handleMouseup, false ); document.addEventListener( 'MSPointerMove', handleMousemove, false ); document.addEventListener( 'MSPointerCancel', cancel, false ); - this.node.addEventListener( 'click', handleMouseup, false ); - } else { - console.log('ractive-events-tap pointerless'); - this.node.addEventListener( 'click', handleMouseup, false ); - document.addEventListener( 'mousemove', handleMousemove, false ); } + console.log('ractive-events-tap pointerless'); + this.node.addEventListener( 'click', handleMouseup, false ); + document.addEventListener( 'mousemove', handleMousemove, false ); setTimeout( cancel, TIME_THRESHOLD ); }, @@ -196,7 +193,7 @@ function handleBlur () { } function handleKeydown ( event ) { - if ( event.which === 32 ) { // space key + if ( event.which === 32 || event.which === 13 ) { // space key this.__tap_handler__.fire(); } } From 74fc7403f626c601e16b78b484463b2c3cd79b48 Mon Sep 17 00:00:00 2001 From: Ivan Wills Date: Tue, 17 Apr 2018 10:49:55 +1000 Subject: [PATCH 05/13] Adding anchor tags to events that support listening to space and enter --- src/ractive-events-tap.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/ractive-events-tap.js b/src/ractive-events-tap.js index 5d49b07..91a5f67 100644 --- a/src/ractive-events-tap.js +++ b/src/ractive-events-tap.js @@ -30,7 +30,7 @@ TapHandler.prototype = { // native buttons, and elements, should fire a tap event // when the space key is pressed - if ( node.tagName === 'BUTTON' || node.type === 'button' ) { + if ( node.tagName === 'A' || node.tagName === 'BUTTON' || node.type === 'button' ) { node.addEventListener( 'focus', handleFocus, false ); } @@ -92,17 +92,14 @@ TapHandler.prototype = { }; if ( window.navigator.pointerEnabled ) { - console.log('ractive-events-tap pointerEnabled'); this.node.addEventListener( 'pointerup', handleMouseup, false ); document.addEventListener( 'pointermove', handleMousemove, false ); document.addEventListener( 'pointercancel', cancel, false ); } else if ( window.navigator.msPointerEnabled ) { - console.log('ractive-events-tap msPointerEnabled'); this.node.addEventListener( 'MSPointerUp', handleMouseup, false ); document.addEventListener( 'MSPointerMove', handleMousemove, false ); document.addEventListener( 'MSPointerCancel', cancel, false ); } - console.log('ractive-events-tap pointerless'); this.node.addEventListener( 'click', handleMouseup, false ); document.addEventListener( 'mousemove', handleMousemove, false ); From d55a68123eb79f028ea22a39dd50fc038dc92fb9 Mon Sep 17 00:00:00 2001 From: Ivan Wills Date: Tue, 17 Apr 2018 10:50:12 +1000 Subject: [PATCH 06/13] New builds --- dist/ractive-events-tap.es.js | 14 ++++---------- dist/ractive-events-tap.umd.js | 14 ++++---------- 2 files changed, 8 insertions(+), 20 deletions(-) diff --git a/dist/ractive-events-tap.es.js b/dist/ractive-events-tap.es.js index 0e46743..8782703 100644 --- a/dist/ractive-events-tap.es.js +++ b/dist/ractive-events-tap.es.js @@ -30,7 +30,7 @@ TapHandler.prototype = { // native buttons, and elements, should fire a tap event // when the space key is pressed - if ( node.tagName === 'BUTTON' || node.type === 'button' ) { + if ( node.tagName === 'A' || node.tagName === 'BUTTON' || node.type === 'button' ) { node.addEventListener( 'focus', handleFocus, false ); } @@ -94,22 +94,16 @@ TapHandler.prototype = { }; if ( window.navigator.pointerEnabled ) { - console.log('ractive-events-tap pointerEnabled'); this.node.addEventListener( 'pointerup', handleMouseup, false ); document.addEventListener( 'pointermove', handleMousemove, false ); document.addEventListener( 'pointercancel', cancel, false ); - this.node.addEventListener( 'click', handleMouseup, false ); } else if ( window.navigator.msPointerEnabled ) { - console.log('ractive-events-tap msPointerEnabled'); this.node.addEventListener( 'MSPointerUp', handleMouseup, false ); document.addEventListener( 'MSPointerMove', handleMousemove, false ); document.addEventListener( 'MSPointerCancel', cancel, false ); - this.node.addEventListener( 'click', handleMouseup, false ); - } else { - console.log('ractive-events-tap pointerless'); - this.node.addEventListener( 'click', handleMouseup, false ); - document.addEventListener( 'mousemove', handleMousemove, false ); } + this.node.addEventListener( 'click', handleMouseup, false ); + document.addEventListener( 'mousemove', handleMousemove, false ); setTimeout( cancel, TIME_THRESHOLD ); }, @@ -200,7 +194,7 @@ function handleBlur () { } function handleKeydown ( event ) { - if ( event.which === 32 ) { // space key + if ( event.which === 32 || event.which === 13 ) { // space key this.__tap_handler__.fire(); } } diff --git a/dist/ractive-events-tap.umd.js b/dist/ractive-events-tap.umd.js index a9caa3c..de26f5f 100644 --- a/dist/ractive-events-tap.umd.js +++ b/dist/ractive-events-tap.umd.js @@ -36,7 +36,7 @@ TapHandler.prototype = { // native buttons, and elements, should fire a tap event // when the space key is pressed - if ( node.tagName === 'BUTTON' || node.type === 'button' ) { + if ( node.tagName === 'A' || node.tagName === 'BUTTON' || node.type === 'button' ) { node.addEventListener( 'focus', handleFocus, false ); } @@ -100,22 +100,16 @@ TapHandler.prototype = { }; if ( window.navigator.pointerEnabled ) { - console.log('ractive-events-tap pointerEnabled'); this.node.addEventListener( 'pointerup', handleMouseup, false ); document.addEventListener( 'pointermove', handleMousemove, false ); document.addEventListener( 'pointercancel', cancel, false ); - this.node.addEventListener( 'click', handleMouseup, false ); } else if ( window.navigator.msPointerEnabled ) { - console.log('ractive-events-tap msPointerEnabled'); this.node.addEventListener( 'MSPointerUp', handleMouseup, false ); document.addEventListener( 'MSPointerMove', handleMousemove, false ); document.addEventListener( 'MSPointerCancel', cancel, false ); - this.node.addEventListener( 'click', handleMouseup, false ); - } else { - console.log('ractive-events-tap pointerless'); - this.node.addEventListener( 'click', handleMouseup, false ); - document.addEventListener( 'mousemove', handleMousemove, false ); } + this.node.addEventListener( 'click', handleMouseup, false ); + document.addEventListener( 'mousemove', handleMousemove, false ); setTimeout( cancel, TIME_THRESHOLD ); }, @@ -206,7 +200,7 @@ function handleBlur () { } function handleKeydown ( event ) { - if ( event.which === 32 ) { // space key + if ( event.which === 32 || event.which === 13 ) { // space key this.__tap_handler__.fire(); } } From 512e1c0d384fc16ae703533cdbd2b706d9c2a1e2 Mon Sep 17 00:00:00 2001 From: Ivan Wills Date: Wed, 18 Apr 2018 09:56:05 +1000 Subject: [PATCH 07/13] Reverting click code for mouse --- src/ractive-events-tap.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/ractive-events-tap.js b/src/ractive-events-tap.js index 91a5f67..060e08a 100644 --- a/src/ractive-events-tap.js +++ b/src/ractive-events-tap.js @@ -99,9 +99,10 @@ TapHandler.prototype = { this.node.addEventListener( 'MSPointerUp', handleMouseup, false ); document.addEventListener( 'MSPointerMove', handleMousemove, false ); document.addEventListener( 'MSPointerCancel', cancel, false ); + } else { + this.node.addEventListener( 'click', handleMouseup, false ); + document.addEventListener( 'mousemove', handleMousemove, false ); } - this.node.addEventListener( 'click', handleMouseup, false ); - document.addEventListener( 'mousemove', handleMousemove, false ); setTimeout( cancel, TIME_THRESHOLD ); }, From e53d23da10319ba0b11ae10470bab5f927a71311 Mon Sep 17 00:00:00 2001 From: Ivan Wills Date: Wed, 18 Apr 2018 10:34:37 +1000 Subject: [PATCH 08/13] Adding handling click events while focused (the way JAWS sends click events from the keyboard) --- src/ractive-events-tap.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/ractive-events-tap.js b/src/ractive-events-tap.js index 060e08a..fc73aaa 100644 --- a/src/ractive-events-tap.js +++ b/src/ractive-events-tap.js @@ -180,18 +180,25 @@ function handleTouchstart ( event ) { this.__tap_handler__.touchdown( event ); } +function handleFocusClick ( event ) { + this.__tap_handler__.fire( event ); +} + function handleFocus () { this.addEventListener( 'keydown', handleKeydown, false ); this.addEventListener( 'blur', handleBlur, false ); + this.addEventListener( 'click', handleFocusClick, false ); } function handleBlur () { this.removeEventListener( 'keydown', handleKeydown, false ); this.removeEventListener( 'blur', handleBlur, false ); + this.removeEventListener( 'click', handleFocusClick, false ); } function handleKeydown ( event ) { if ( event.which === 32 || event.which === 13 ) { // space key + this.removeEventListener( 'click', handleFocusClick, false ); this.__tap_handler__.fire(); } } From 2435401944ff49ae884b38e10254ea392ca7115e Mon Sep 17 00:00:00 2001 From: Ivan Wills Date: Wed, 18 Apr 2018 10:36:20 +1000 Subject: [PATCH 09/13] Built the code --- dist/ractive-events-tap.es.js | 12 ++++++++++-- dist/ractive-events-tap.umd.js | 12 ++++++++++-- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/dist/ractive-events-tap.es.js b/dist/ractive-events-tap.es.js index 8782703..3b78078 100644 --- a/dist/ractive-events-tap.es.js +++ b/dist/ractive-events-tap.es.js @@ -101,9 +101,10 @@ TapHandler.prototype = { this.node.addEventListener( 'MSPointerUp', handleMouseup, false ); document.addEventListener( 'MSPointerMove', handleMousemove, false ); document.addEventListener( 'MSPointerCancel', cancel, false ); + } else { + this.node.addEventListener( 'click', handleMouseup, false ); + document.addEventListener( 'mousemove', handleMousemove, false ); } - this.node.addEventListener( 'click', handleMouseup, false ); - document.addEventListener( 'mousemove', handleMousemove, false ); setTimeout( cancel, TIME_THRESHOLD ); }, @@ -183,18 +184,25 @@ function handleTouchstart ( event ) { this.__tap_handler__.touchdown( event ); } +function handleFocusClick ( event ) { + this.__tap_handler__.fire( event ); +} + function handleFocus () { this.addEventListener( 'keydown', handleKeydown, false ); this.addEventListener( 'blur', handleBlur, false ); + this.addEventListener( 'click', handleFocusClick, false ); } function handleBlur () { this.removeEventListener( 'keydown', handleKeydown, false ); this.removeEventListener( 'blur', handleBlur, false ); + this.removeEventListener( 'click', handleFocusClick, false ); } function handleKeydown ( event ) { if ( event.which === 32 || event.which === 13 ) { // space key + this.removeEventListener( 'click', handleFocusClick, false ); this.__tap_handler__.fire(); } } diff --git a/dist/ractive-events-tap.umd.js b/dist/ractive-events-tap.umd.js index de26f5f..716d770 100644 --- a/dist/ractive-events-tap.umd.js +++ b/dist/ractive-events-tap.umd.js @@ -107,9 +107,10 @@ TapHandler.prototype = { this.node.addEventListener( 'MSPointerUp', handleMouseup, false ); document.addEventListener( 'MSPointerMove', handleMousemove, false ); document.addEventListener( 'MSPointerCancel', cancel, false ); + } else { + this.node.addEventListener( 'click', handleMouseup, false ); + document.addEventListener( 'mousemove', handleMousemove, false ); } - this.node.addEventListener( 'click', handleMouseup, false ); - document.addEventListener( 'mousemove', handleMousemove, false ); setTimeout( cancel, TIME_THRESHOLD ); }, @@ -189,18 +190,25 @@ function handleTouchstart ( event ) { this.__tap_handler__.touchdown( event ); } +function handleFocusClick ( event ) { + this.__tap_handler__.fire( event ); +} + function handleFocus () { this.addEventListener( 'keydown', handleKeydown, false ); this.addEventListener( 'blur', handleBlur, false ); + this.addEventListener( 'click', handleFocusClick, false ); } function handleBlur () { this.removeEventListener( 'keydown', handleKeydown, false ); this.removeEventListener( 'blur', handleBlur, false ); + this.removeEventListener( 'click', handleFocusClick, false ); } function handleKeydown ( event ) { if ( event.which === 32 || event.which === 13 ) { // space key + this.removeEventListener( 'click', handleFocusClick, false ); this.__tap_handler__.fire(); } } From e76a9d556299557db2075a8574bde66d8c1776fd Mon Sep 17 00:00:00 2001 From: Ivan Wills Date: Wed, 18 Apr 2018 14:28:16 +1000 Subject: [PATCH 10/13] Adding code to prevent double firing of click event --- src/ractive-events-tap.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/ractive-events-tap.js b/src/ractive-events-tap.js index fc73aaa..b13ab3a 100644 --- a/src/ractive-events-tap.js +++ b/src/ractive-events-tap.js @@ -10,6 +10,7 @@ function TapHandler ( node, callback ) { this.callback = callback; this.preventMousedownEvents = false; + this.preventClickEvents = false; this.bind( node ); } @@ -55,6 +56,7 @@ TapHandler.prototype = { return; } + this.preventClickEvents = true; const x = event.clientX; const y = event.clientY; @@ -104,6 +106,7 @@ TapHandler.prototype = { document.addEventListener( 'mousemove', handleMousemove, false ); } + this.node.removeEventListener( 'click', handleFocusClick, false ); setTimeout( cancel, TIME_THRESHOLD ); }, @@ -181,7 +184,9 @@ function handleTouchstart ( event ) { } function handleFocusClick ( event ) { - this.__tap_handler__.fire( event ); + if (! this.__tap_handler__.preventClickEvents) { + this.__tap_handler__.fire( event ); + } } function handleFocus () { @@ -194,6 +199,7 @@ function handleBlur () { this.removeEventListener( 'keydown', handleKeydown, false ); this.removeEventListener( 'blur', handleBlur, false ); this.removeEventListener( 'click', handleFocusClick, false ); + this.__tap_handler__.preventClickEvents = false; } function handleKeydown ( event ) { From 9ff330d1e97258bea7aac1f1fb1c29e24a38f47c Mon Sep 17 00:00:00 2001 From: Ivan Wills Date: Wed, 18 Apr 2018 14:28:51 +1000 Subject: [PATCH 11/13] Rebuilding dist files --- dist/ractive-events-tap.es.js | 8 +++++++- dist/ractive-events-tap.umd.js | 8 +++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/dist/ractive-events-tap.es.js b/dist/ractive-events-tap.es.js index 3b78078..4fe660f 100644 --- a/dist/ractive-events-tap.es.js +++ b/dist/ractive-events-tap.es.js @@ -10,6 +10,7 @@ function TapHandler ( node, callback ) { this.callback = callback; this.preventMousedownEvents = false; + this.preventClickEvents = false; this.bind( node ); } @@ -57,6 +58,7 @@ TapHandler.prototype = { return; } + this.preventClickEvents = true; var x = event.clientX; var y = event.clientY; @@ -106,6 +108,7 @@ TapHandler.prototype = { document.addEventListener( 'mousemove', handleMousemove, false ); } + this.node.removeEventListener( 'click', handleFocusClick, false ); setTimeout( cancel, TIME_THRESHOLD ); }, @@ -185,7 +188,9 @@ function handleTouchstart ( event ) { } function handleFocusClick ( event ) { - this.__tap_handler__.fire( event ); + if (! this.__tap_handler__.preventClickEvents) { + this.__tap_handler__.fire( event ); + } } function handleFocus () { @@ -198,6 +203,7 @@ function handleBlur () { this.removeEventListener( 'keydown', handleKeydown, false ); this.removeEventListener( 'blur', handleBlur, false ); this.removeEventListener( 'click', handleFocusClick, false ); + this.__tap_handler__.preventClickEvents = false; } function handleKeydown ( event ) { diff --git a/dist/ractive-events-tap.umd.js b/dist/ractive-events-tap.umd.js index 716d770..7e8edcb 100644 --- a/dist/ractive-events-tap.umd.js +++ b/dist/ractive-events-tap.umd.js @@ -16,6 +16,7 @@ function TapHandler ( node, callback ) { this.callback = callback; this.preventMousedownEvents = false; + this.preventClickEvents = false; this.bind( node ); } @@ -63,6 +64,7 @@ TapHandler.prototype = { return; } + this.preventClickEvents = true; var x = event.clientX; var y = event.clientY; @@ -112,6 +114,7 @@ TapHandler.prototype = { document.addEventListener( 'mousemove', handleMousemove, false ); } + this.node.removeEventListener( 'click', handleFocusClick, false ); setTimeout( cancel, TIME_THRESHOLD ); }, @@ -191,7 +194,9 @@ function handleTouchstart ( event ) { } function handleFocusClick ( event ) { - this.__tap_handler__.fire( event ); + if (! this.__tap_handler__.preventClickEvents) { + this.__tap_handler__.fire( event ); + } } function handleFocus () { @@ -204,6 +209,7 @@ function handleBlur () { this.removeEventListener( 'keydown', handleKeydown, false ); this.removeEventListener( 'blur', handleBlur, false ); this.removeEventListener( 'click', handleFocusClick, false ); + this.__tap_handler__.preventClickEvents = false; } function handleKeydown ( event ) { From b87707353cf386df7fcd28dd723ea65631c2deee Mon Sep 17 00:00:00 2001 From: Ivan Wills Date: Wed, 30 May 2018 10:48:06 +1000 Subject: [PATCH 12/13] Changing way click events are listened to --- dist/ractive-events-tap.es.js | 36 +++++++++++++++++------------ dist/ractive-events-tap.umd.js | 36 +++++++++++++++++------------ src/ractive-events-tap.js | 42 ++++++++++++++++++++-------------- 3 files changed, 69 insertions(+), 45 deletions(-) diff --git a/dist/ractive-events-tap.es.js b/dist/ractive-events-tap.es.js index 4fe660f..09142d6 100644 --- a/dist/ractive-events-tap.es.js +++ b/dist/ractive-events-tap.es.js @@ -10,7 +10,6 @@ function TapHandler ( node, callback ) { this.callback = callback; this.preventMousedownEvents = false; - this.preventClickEvents = false; this.bind( node ); } @@ -18,9 +17,9 @@ function TapHandler ( node, callback ) { TapHandler.prototype = { bind: function bind ( node ) { // listen for mouse/pointer events... - if (window.navigator.pointerEnabled) { + if ( window.navigator.pointerEnabled ) { node.addEventListener( 'pointerdown', handleMousedown, false ); - } else if (window.navigator.msPointerEnabled) { + } else if ( window.navigator.msPointerEnabled ) { node.addEventListener( 'MSPointerDown', handleMousedown, false ); } else { node.addEventListener( 'mousedown', handleMousedown, false ); @@ -29,6 +28,9 @@ TapHandler.prototype = { node.addEventListener( 'touchstart', handleTouchstart, false ); } + // ...and random click events + node.addEventListener( 'click', handleRealClick, false ); + // native buttons, and elements, should fire a tap event // when the space key is pressed if ( node.tagName === 'A' || node.tagName === 'BUTTON' || node.type === 'button' ) { @@ -58,7 +60,9 @@ TapHandler.prototype = { return; } - this.preventClickEvents = true; + // Remove click handler while normal mouse events in progress + this.node.removeEventListener( 'click', handleRealClick, false ); + var x = event.clientX; var y = event.clientY; @@ -84,6 +88,12 @@ TapHandler.prototype = { } }; + var cancelFakeClick = function () { + // remove this event and add back original event + this$1.node.removeEventListener( 'click', cancelFakeClick, false ); + this$1.node.addEventListener( 'click', handleRealClick, false ); + } + var cancel = function () { this$1.node.removeEventListener( 'MSPointerUp', handleMouseup, false ); document.removeEventListener( 'MSPointerMove', handleMousemove, false ); @@ -93,6 +103,11 @@ TapHandler.prototype = { document.removeEventListener( 'pointercancel', cancel, false ); this$1.node.removeEventListener( 'click', handleMouseup, false ); document.removeEventListener( 'mousemove', handleMousemove, false ); + + // prepare to add back real click handler when done + this$1.node.addEventListener( 'click', cancelFakeClick, false ); + // if no click event fired then restore the real click event any way + setTimeout( cancelFakeClick, TIME_THRESHOLD ); }; if ( window.navigator.pointerEnabled ) { @@ -108,11 +123,10 @@ TapHandler.prototype = { document.addEventListener( 'mousemove', handleMousemove, false ); } - this.node.removeEventListener( 'click', handleFocusClick, false ); setTimeout( cancel, TIME_THRESHOLD ); }, - touchdown: function touchdown ( event ) { + touchdown: function touchdown () { var this$1 = this; var touch = event.touches[0]; @@ -187,28 +201,22 @@ function handleTouchstart ( event ) { this.__tap_handler__.touchdown( event ); } -function handleFocusClick ( event ) { - if (! this.__tap_handler__.preventClickEvents) { - this.__tap_handler__.fire( event ); - } +function handleRealClick ( event ) { + this.__tap_handler__.fire( event ); } function handleFocus () { this.addEventListener( 'keydown', handleKeydown, false ); this.addEventListener( 'blur', handleBlur, false ); - this.addEventListener( 'click', handleFocusClick, false ); } function handleBlur () { this.removeEventListener( 'keydown', handleKeydown, false ); this.removeEventListener( 'blur', handleBlur, false ); - this.removeEventListener( 'click', handleFocusClick, false ); - this.__tap_handler__.preventClickEvents = false; } function handleKeydown ( event ) { if ( event.which === 32 || event.which === 13 ) { // space key - this.removeEventListener( 'click', handleFocusClick, false ); this.__tap_handler__.fire(); } } diff --git a/dist/ractive-events-tap.umd.js b/dist/ractive-events-tap.umd.js index 7e8edcb..31e4517 100644 --- a/dist/ractive-events-tap.umd.js +++ b/dist/ractive-events-tap.umd.js @@ -16,7 +16,6 @@ function TapHandler ( node, callback ) { this.callback = callback; this.preventMousedownEvents = false; - this.preventClickEvents = false; this.bind( node ); } @@ -24,9 +23,9 @@ function TapHandler ( node, callback ) { TapHandler.prototype = { bind: function bind ( node ) { // listen for mouse/pointer events... - if (window.navigator.pointerEnabled) { + if ( window.navigator.pointerEnabled ) { node.addEventListener( 'pointerdown', handleMousedown, false ); - } else if (window.navigator.msPointerEnabled) { + } else if ( window.navigator.msPointerEnabled ) { node.addEventListener( 'MSPointerDown', handleMousedown, false ); } else { node.addEventListener( 'mousedown', handleMousedown, false ); @@ -35,6 +34,9 @@ TapHandler.prototype = { node.addEventListener( 'touchstart', handleTouchstart, false ); } + // ...and random click events + node.addEventListener( 'click', handleRealClick, false ); + // native buttons, and elements, should fire a tap event // when the space key is pressed if ( node.tagName === 'A' || node.tagName === 'BUTTON' || node.type === 'button' ) { @@ -64,7 +66,9 @@ TapHandler.prototype = { return; } - this.preventClickEvents = true; + // Remove click handler while normal mouse events in progress + this.node.removeEventListener( 'click', handleRealClick, false ); + var x = event.clientX; var y = event.clientY; @@ -90,6 +94,12 @@ TapHandler.prototype = { } }; + var cancelFakeClick = function () { + // remove this event and add back original event + this$1.node.removeEventListener( 'click', cancelFakeClick, false ); + this$1.node.addEventListener( 'click', handleRealClick, false ); + } + var cancel = function () { this$1.node.removeEventListener( 'MSPointerUp', handleMouseup, false ); document.removeEventListener( 'MSPointerMove', handleMousemove, false ); @@ -99,6 +109,11 @@ TapHandler.prototype = { document.removeEventListener( 'pointercancel', cancel, false ); this$1.node.removeEventListener( 'click', handleMouseup, false ); document.removeEventListener( 'mousemove', handleMousemove, false ); + + // prepare to add back real click handler when done + this$1.node.addEventListener( 'click', cancelFakeClick, false ); + // if no click event fired then restore the real click event any way + setTimeout( cancelFakeClick, TIME_THRESHOLD ); }; if ( window.navigator.pointerEnabled ) { @@ -114,11 +129,10 @@ TapHandler.prototype = { document.addEventListener( 'mousemove', handleMousemove, false ); } - this.node.removeEventListener( 'click', handleFocusClick, false ); setTimeout( cancel, TIME_THRESHOLD ); }, - touchdown: function touchdown ( event ) { + touchdown: function touchdown () { var this$1 = this; var touch = event.touches[0]; @@ -193,28 +207,22 @@ function handleTouchstart ( event ) { this.__tap_handler__.touchdown( event ); } -function handleFocusClick ( event ) { - if (! this.__tap_handler__.preventClickEvents) { - this.__tap_handler__.fire( event ); - } +function handleRealClick ( event ) { + this.__tap_handler__.fire( event ); } function handleFocus () { this.addEventListener( 'keydown', handleKeydown, false ); this.addEventListener( 'blur', handleBlur, false ); - this.addEventListener( 'click', handleFocusClick, false ); } function handleBlur () { this.removeEventListener( 'keydown', handleKeydown, false ); this.removeEventListener( 'blur', handleBlur, false ); - this.removeEventListener( 'click', handleFocusClick, false ); - this.__tap_handler__.preventClickEvents = false; } function handleKeydown ( event ) { if ( event.which === 32 || event.which === 13 ) { // space key - this.removeEventListener( 'click', handleFocusClick, false ); this.__tap_handler__.fire(); } } diff --git a/src/ractive-events-tap.js b/src/ractive-events-tap.js index b13ab3a..c76b9ae 100644 --- a/src/ractive-events-tap.js +++ b/src/ractive-events-tap.js @@ -10,7 +10,6 @@ function TapHandler ( node, callback ) { this.callback = callback; this.preventMousedownEvents = false; - this.preventClickEvents = false; this.bind( node ); } @@ -18,17 +17,20 @@ function TapHandler ( node, callback ) { TapHandler.prototype = { bind ( node ) { // listen for mouse/pointer events... - if (window.navigator.pointerEnabled) { + if ( window.navigator.pointerEnabled ) { node.addEventListener( 'pointerdown', handleMousedown, false ); - } else if (window.navigator.msPointerEnabled) { + } else if ( window.navigator.msPointerEnabled ) { node.addEventListener( 'MSPointerDown', handleMousedown, false ); } else { node.addEventListener( 'mousedown', handleMousedown, false ); - - // ...and touch events - node.addEventListener( 'touchstart', handleTouchstart, false ); } + // ...and touch events + node.addEventListener( 'touchstart', handleTouchstart, false ); + + // ...and random click events + node.addEventListener( 'click', handleRealClick, false ); + // native buttons, and elements, should fire a tap event // when the space key is pressed if ( node.tagName === 'A' || node.tagName === 'BUTTON' || node.type === 'button' ) { @@ -56,7 +58,9 @@ TapHandler.prototype = { return; } - this.preventClickEvents = true; + // Remove click handler while normal mouse events in progress + this.node.removeEventListener( 'click', handleRealClick, false ); + const x = event.clientX; const y = event.clientY; @@ -82,6 +86,12 @@ TapHandler.prototype = { } }; + const cancelFakeClick = () => { + // remove this event and add back original event + this.node.removeEventListener( 'click', cancelFakeClick, false ); + this.node.addEventListener( 'click', handleRealClick, false ); + } + const cancel = () => { this.node.removeEventListener( 'MSPointerUp', handleMouseup, false ); document.removeEventListener( 'MSPointerMove', handleMousemove, false ); @@ -91,6 +101,11 @@ TapHandler.prototype = { document.removeEventListener( 'pointercancel', cancel, false ); this.node.removeEventListener( 'click', handleMouseup, false ); document.removeEventListener( 'mousemove', handleMousemove, false ); + + // prepare to add back real click handler when done + this.node.addEventListener( 'click', cancelFakeClick, false ); + // if no click event fired then restore the real click event any way + setTimeout( cancelFakeClick, TIME_THRESHOLD ); }; if ( window.navigator.pointerEnabled ) { @@ -106,11 +121,10 @@ TapHandler.prototype = { document.addEventListener( 'mousemove', handleMousemove, false ); } - this.node.removeEventListener( 'click', handleFocusClick, false ); setTimeout( cancel, TIME_THRESHOLD ); }, - touchdown ( event ) { + touchdown () { const touch = event.touches[0]; const x = touch.clientX; @@ -183,28 +197,22 @@ function handleTouchstart ( event ) { this.__tap_handler__.touchdown( event ); } -function handleFocusClick ( event ) { - if (! this.__tap_handler__.preventClickEvents) { - this.__tap_handler__.fire( event ); - } +function handleRealClick ( event ) { + this.__tap_handler__.fire( event ); } function handleFocus () { this.addEventListener( 'keydown', handleKeydown, false ); this.addEventListener( 'blur', handleBlur, false ); - this.addEventListener( 'click', handleFocusClick, false ); } function handleBlur () { this.removeEventListener( 'keydown', handleKeydown, false ); this.removeEventListener( 'blur', handleBlur, false ); - this.removeEventListener( 'click', handleFocusClick, false ); - this.__tap_handler__.preventClickEvents = false; } function handleKeydown ( event ) { if ( event.which === 32 || event.which === 13 ) { // space key - this.removeEventListener( 'click', handleFocusClick, false ); this.__tap_handler__.fire(); } } From 2e58ee636a9a700d7b062c6f82a4cbfba9ce4ebf Mon Sep 17 00:00:00 2001 From: Ivan Wills Date: Wed, 30 May 2018 11:11:10 +1000 Subject: [PATCH 13/13] Reverted missing event --- dist/ractive-events-tap.es.js | 8 ++++---- dist/ractive-events-tap.umd.js | 8 ++++---- src/ractive-events-tap.js | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/dist/ractive-events-tap.es.js b/dist/ractive-events-tap.es.js index 09142d6..2a9f787 100644 --- a/dist/ractive-events-tap.es.js +++ b/dist/ractive-events-tap.es.js @@ -23,11 +23,11 @@ TapHandler.prototype = { node.addEventListener( 'MSPointerDown', handleMousedown, false ); } else { node.addEventListener( 'mousedown', handleMousedown, false ); - - // ...and touch events - node.addEventListener( 'touchstart', handleTouchstart, false ); } + // ...and touch events + node.addEventListener( 'touchstart', handleTouchstart, false ); + // ...and random click events node.addEventListener( 'click', handleRealClick, false ); @@ -126,7 +126,7 @@ TapHandler.prototype = { setTimeout( cancel, TIME_THRESHOLD ); }, - touchdown: function touchdown () { + touchdown: function touchdown ( event ) { var this$1 = this; var touch = event.touches[0]; diff --git a/dist/ractive-events-tap.umd.js b/dist/ractive-events-tap.umd.js index 31e4517..269c147 100644 --- a/dist/ractive-events-tap.umd.js +++ b/dist/ractive-events-tap.umd.js @@ -29,11 +29,11 @@ TapHandler.prototype = { node.addEventListener( 'MSPointerDown', handleMousedown, false ); } else { node.addEventListener( 'mousedown', handleMousedown, false ); - - // ...and touch events - node.addEventListener( 'touchstart', handleTouchstart, false ); } + // ...and touch events + node.addEventListener( 'touchstart', handleTouchstart, false ); + // ...and random click events node.addEventListener( 'click', handleRealClick, false ); @@ -132,7 +132,7 @@ TapHandler.prototype = { setTimeout( cancel, TIME_THRESHOLD ); }, - touchdown: function touchdown () { + touchdown: function touchdown ( event ) { var this$1 = this; var touch = event.touches[0]; diff --git a/src/ractive-events-tap.js b/src/ractive-events-tap.js index c76b9ae..a17dad1 100644 --- a/src/ractive-events-tap.js +++ b/src/ractive-events-tap.js @@ -124,7 +124,7 @@ TapHandler.prototype = { setTimeout( cancel, TIME_THRESHOLD ); }, - touchdown () { + touchdown ( event ) { const touch = event.touches[0]; const x = touch.clientX;