From 60dd04a540447bd6b0ae008634836181431362dd Mon Sep 17 00:00:00 2001 From: JFH <20402845+jfhenon@users.noreply.github.com> Date: Wed, 5 Jan 2022 23:39:07 -0300 Subject: [PATCH] Update touch.js --- src/svgcanvas/touch.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/svgcanvas/touch.js b/src/svgcanvas/touch.js index 2dc37f5c..e3285e76 100644 --- a/src/svgcanvas/touch.js +++ b/src/svgcanvas/touch.js @@ -5,6 +5,7 @@ * @returns {void} */ const touchHandler = (ev) => { + ev.preventDefault() const { changedTouches } = ev const first = changedTouches[0] @@ -39,13 +40,12 @@ const touchHandler = (ev) => { }) if (changedTouches.length < 2) { first.target.dispatchEvent(simulatedEvent) - ev.preventDefault() } } -export const init = (_svgCanvas) => { - document.addEventListener('touchstart', touchHandler, true) - document.addEventListener('touchmove', touchHandler, true) - document.addEventListener('touchend', touchHandler, true) - document.addEventListener('touchcancel', touchHandler, true) +export const init = (svgCanvas) => { + svgCanvas.svgroot.addEventListener('touchstart', touchHandler) + svgCanvas.svgroot.addEventListener('touchmove', touchHandler) + svgCanvas.svgroot.addEventListener('touchend', touchHandler) + svgCanvas.svgroot.addEventListener('touchcancel', touchHandler) }