@@ -59,9 +59,20 @@ var Events = {
59
59
internalEv . emit ( event , data ) ;
60
60
} ;
61
61
62
- // Add a dummy event handler for 'wheel' event for Safari
63
- // to enable mouse wheel zoom.
64
- addDummyScrollEventListener ( plotObj ) ;
62
+ /*
63
+ * Add a dummy event handler for 'wheel' event for Safari
64
+ * to enable mouse wheel zoom.
65
+ * https://github.com/d3/d3/issues/3035
66
+ * https://github.com/plotly/plotly.js/issues/7452
67
+ *
68
+ * We set {passive: true} for better performance
69
+ * and to avoid a Violation warning in Chromium.
70
+ * https://github.com/WICG/EventListenerOptions/blob/gh-pages/explainer.md
71
+ * https://github.com/plotly/plotly.js/issues/7516
72
+ */
73
+ if ( typeof plotObj . addEventListener === 'function' ) {
74
+ plotObj . addEventListener ( "wheel" , ( ) => { } , { passive : true } ) ;
75
+ }
65
76
66
77
return plotObj ;
67
78
} ,
@@ -134,35 +145,4 @@ var Events = {
134
145
135
146
} ;
136
147
137
- function addDummyScrollEventListener ( plotObj ) {
138
- /*
139
- * Add a dummy event handler for 'wheel' event for Safari
140
- * to enable mouse wheel zoom.
141
- * https://github.com/d3/d3/issues/3035
142
- * https://github.com/plotly/plotly.js/issues/7452
143
- *
144
- * We set {passive: true} for better performance
145
- * and to avoid a Violation warning in Chromium.
146
- * https://github.com/WICG/EventListenerOptions/blob/gh-pages/explainer.md
147
- * https://github.com/plotly/plotly.js/issues/7516
148
- */
149
-
150
- // Test whether the passive property is accessed (for compatibility with older browsers)
151
- var supportsPassive = false ;
152
- try {
153
- var opts = Object . defineProperty ( { } , 'passive' , {
154
- get : function ( ) {
155
- supportsPassive = true ;
156
- }
157
- } ) ;
158
- window . addEventListener ( "testPassive" , null , opts ) ;
159
- window . removeEventListener ( "testPassive" , null , opts ) ;
160
- } catch ( e ) { }
161
-
162
- if ( typeof plotObj . addEventListener === 'function' ) {
163
- plotObj . addEventListener ( "wheel" , ( ) => { } , supportsPassive ? { passive : true } : false ) ;
164
- }
165
-
166
- }
167
-
168
148
module . exports = Events ;
0 commit comments