Skip to content

Commit 4054a61

Browse files
committed
simplify by removing handling for very old browsers
1 parent 2f65ccd commit 4054a61

File tree

1 file changed

+14
-34
lines changed

1 file changed

+14
-34
lines changed

src/lib/events.js

Lines changed: 14 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,20 @@ var Events = {
5959
internalEv.emit(event, data);
6060
};
6161

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+
}
6576

6677
return plotObj;
6778
},
@@ -134,35 +145,4 @@ var Events = {
134145

135146
};
136147

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-
168148
module.exports = Events;

0 commit comments

Comments
 (0)