summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJesus Fernandez <jesus.fernandez@qt.io>2018-03-02 16:53:04 +0100
committerJesus Fernandez <Jesus.Fernandez@qt.io>2018-03-22 14:31:49 +0000
commit50a4e6758786b0946b05327af7a3642121e5cff3 (patch)
treead41dfda5f18128c8fe84ccf9f73b83f3f3ec93e /src
parent27474e156297aeb33f3fde007c9b1467eae08571 (diff)
Fix browser warning and use addEventListener
[Violation] Added non-passive event listener to a scroll-blocking event. Consider marking event handler as 'passive' to make the page more responsive. See https://www.chromestatus.com/feature/5745543795965952 This patch also uses addEventListener instead of assigning the callback directly to the function to be able to mark the event as passive. Change-Id: I6c2336eed0cc4bc562fff09a08737815eaa864ce Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/plugins/platforms/webgl/webqt.jsx16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/plugins/platforms/webgl/webqt.jsx b/src/plugins/platforms/webgl/webqt.jsx
index be3195a..6a4e942 100644
--- a/src/plugins/platforms/webgl/webqt.jsx
+++ b/src/plugins/platforms/webgl/webqt.jsx
@@ -267,10 +267,10 @@ window.onload = function () {
event.returnValue = false;
}
- if ("onmousewheel" in canvas)
- canvas.onmousewheel = handleMouseWheel;
- else
- canvas.addEventListener('DOMMouseScroll', handleMouseWheel, false);
+ // Internet Explorer, Opera, Chrome and Safari
+ canvas.addEventListener('mousewheel', handleMouseWheel, { passive: true });
+ // Firefox
+ canvas.addEventListener('DOMMouseScroll', handleMouseWheel, { passive: true });
function handleTouch(event) {
var object = {};
@@ -323,10 +323,10 @@ window.onload = function () {
event.returnValue = false;
}
- canvas.addEventListener("touchstart", handleTouch, false);
- canvas.addEventListener("touchend", handleTouch, false);
- canvas.addEventListener("touchcancel", handleTouch, false);
- canvas.addEventListener("touchmove", handleTouch, false);
+ canvas.addEventListener("touchstart", handleTouch, { passive: true });
+ canvas.addEventListener("touchend", handleTouch, { passive: true });
+ canvas.addEventListener("touchcancel", handleTouch, { passive: true });
+ canvas.addEventListener("touchmove", handleTouch, { passive: true });
canvas.oncontextmenu = function (event) {
event.preventDefault();