@@ -36,7 +36,7 @@ export var LN_TEN = Math.log(LOG_SCALE);
36
36
*/
37
37
export var log10 = function ( x ) {
38
38
return Math . log ( x ) / LN_TEN ;
39
- } ;
39
+ }
40
40
41
41
/**
42
42
* @private
@@ -69,7 +69,7 @@ export var logRangeFraction = function(r0, r1, pct) {
69
69
var exponent = logr0 + ( pct * ( logr1 - logr0 ) ) ;
70
70
var value = Math . pow ( LOG_SCALE , exponent ) ;
71
71
return value ;
72
- } ;
72
+ }
73
73
74
74
/** A dotted line stroke pattern. */
75
75
export var DOTTED_LINE = [ 2 , 2 ] ;
@@ -95,7 +95,18 @@ export var VERTICAL = 2;
95
95
*/
96
96
export var getContext = function ( canvas ) {
97
97
return /** @type {!CanvasRenderingContext2D }*/ ( canvas . getContext ( "2d" ) ) ;
98
- } ;
98
+ }
99
+
100
+ /**
101
+ * EventListener options
102
+ */
103
+ function _eventListenerOptions ( type ) {
104
+ const options = { capture : false } ;
105
+ if ( type === 'touchstart' || type === 'touchmove' ) {
106
+ options . passive = true ;
107
+ }
108
+ return options ;
109
+ }
99
110
100
111
/**
101
112
* Add an event handler.
@@ -106,8 +117,8 @@ export var getContext = function(canvas) {
106
117
* @private
107
118
*/
108
119
export var addEvent = function addEvent ( elem , type , fn ) {
109
- elem . addEventListener ( type , fn , false ) ;
110
- } ;
120
+ elem . addEventListener ( type , fn , _eventListenerOptions ( type ) ) ;
121
+ }
111
122
112
123
/**
113
124
* Remove an event handler.
@@ -117,7 +128,7 @@ export var addEvent = function addEvent(elem, type, fn) {
117
128
* on the event. The function takes one parameter: the event object.
118
129
*/
119
130
export function removeEvent ( elem , type , fn ) {
120
- elem . removeEventListener ( type , fn , false ) ;
131
+ elem . removeEventListener ( type , fn , _eventListenerOptions ( type ) ) ;
121
132
}
122
133
123
134
/**
0 commit comments