From 3e34d49e98588fd7c04970cd51140fd8c21d5621 Mon Sep 17 00:00:00 2001 From: Alex Bernal Date: Sun, 5 Aug 2018 15:33:42 -0500 Subject: [PATCH] Passive listeners, Touch devices The touch move events need to block the call to preventDefault (), for a better touch response, the delay in scrolling could improve up to 300 [ms], the test was done on Ipad Air 2 with the audit function of Chrome. With `{passive: true}` touch and wheel listeners, the Developers promises not to call preventDefault () to disable scrolling. --- app/ui.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/app/ui.js b/app/ui.js index f3c6d46d..d344fe87 100644 --- a/app/ui.js +++ b/app/ui.js @@ -257,27 +257,28 @@ var UI = { document.documentElement .addEventListener('mousedown', UI.keepVirtualKeyboard, true); - + + // passive event listeners won't call preventDefault() to disable scrolling document.getElementById("noVNC_control_bar") - .addEventListener('touchstart', UI.activateControlbar); + .addEventListener('touchstart', UI.activateControlbar, {passive: true}); document.getElementById("noVNC_control_bar") - .addEventListener('touchmove', UI.activateControlbar); + .addEventListener('touchmove', UI.activateControlbar, {passive: true}); document.getElementById("noVNC_control_bar") .addEventListener('touchend', UI.activateControlbar); document.getElementById("noVNC_control_bar") .addEventListener('input', UI.activateControlbar); document.getElementById("noVNC_control_bar") - .addEventListener('touchstart', UI.keepControlbar); + .addEventListener('touchstart', UI.keepControlbar, {passive: true}); document.getElementById("noVNC_control_bar") .addEventListener('input', UI.keepControlbar); document.getElementById("noVNC_control_bar_handle") - .addEventListener('touchstart', UI.controlbarHandleMouseDown); + .addEventListener('touchstart', UI.controlbarHandleMouseDown, {passive: true}); document.getElementById("noVNC_control_bar_handle") .addEventListener('touchend', UI.controlbarHandleMouseUp); document.getElementById("noVNC_control_bar_handle") - .addEventListener('touchmove', UI.dragControlbarHandle); + .addEventListener('touchmove', UI.dragControlbarHandle, {passive: true}); }, addExtraKeysHandlers: function() {