From 5c474418b1c38af75cd90805cb7786f8a21223e6 Mon Sep 17 00:00:00 2001 From: Andrea Bogazzi Date: Sat, 28 Apr 2018 00:36:17 +0200 Subject: [PATCH] Register mousemove as non passive to help touch devices (#4933) * fix-event-reg * this was the file * take care of touch-action too --- package.json | 2 +- src/canvas.class.js | 2 +- src/mixins/canvas_events.mixin.js | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index 4c5c8bdb6ab..3121e893431 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,7 @@ "build": "node build.js modules=ALL requirejs exclude=gestures,accessors", "build:fast": "node build.js modules=ALL requirejs fast exclude=gestures,accessors", "build:watch": "onchange 'src/**/**' 'HEADER.js' 'lib/**/**' -- npm run build_export", - "build_with_gestures": "node build.js modules=ALL exclude=json", + "build_with_gestures": "node build.js modules=ALL exclude=accessors", "build_export": "npm run build:fast && npm run export_dist_to_site", "test": "node test.js", "lint": "eslint --config .eslintrc.json src", diff --git a/src/canvas.class.js b/src/canvas.class.js index ba425fa4ed1..055e78ae1a3 100644 --- a/src/canvas.class.js +++ b/src/canvas.class.js @@ -1362,7 +1362,7 @@ height: height + 'px', left: 0, top: 0, - 'touch-action': 'none' + 'touch-action': this.allowTouchScrolling ? 'manipulation' : 'none' }); element.width = width; element.height = height; diff --git a/src/mixins/canvas_events.mixin.js b/src/mixins/canvas_events.mixin.js index 0c9c222d145..8785246fa57 100644 --- a/src/mixins/canvas_events.mixin.js +++ b/src/mixins/canvas_events.mixin.js @@ -52,7 +52,7 @@ // mouse events addListener(this.upperCanvasEl, 'mousedown', this._onMouseDown); addListener(this.upperCanvasEl, 'dblclick', this._onDoubleClick); - addListener(this.upperCanvasEl, 'mousemove', this._onMouseMove); + addListener(this.upperCanvasEl, 'mousemove', this._onMouseMove, addEventOptions); addListener(this.upperCanvasEl, 'mouseout', this._onMouseOut); addListener(this.upperCanvasEl, 'mouseenter', this._onMouseEnter); addListener(this.upperCanvasEl, 'wheel', this._onMouseWheel); @@ -255,7 +255,7 @@ addListener(fabric.document, 'touchmove', this._onMouseMove, addEventOptions); removeListener(this.upperCanvasEl, 'mousemove', this._onMouseMove); - removeListener(this.upperCanvasEl, 'touchmove', this._onMouseMove, addEventOptions); + removeListener(this.upperCanvasEl, 'touchmove', this._onMouseMove); if (e.type === 'touchstart') { // Unbind mousedown to prevent double triggers from touch devices @@ -278,9 +278,9 @@ removeListener(fabric.document, 'touchend', this._onMouseUp, addEventOptions); removeListener(fabric.document, 'mousemove', this._onMouseMove); - removeListener(fabric.document, 'touchmove', this._onMouseMove, addEventOptions); + removeListener(fabric.document, 'touchmove', this._onMouseMove); - addListener(this.upperCanvasEl, 'mousemove', this._onMouseMove); + addListener(this.upperCanvasEl, 'mousemove', this._onMouseMove, addEventOptions); addListener(this.upperCanvasEl, 'touchmove', this._onMouseMove, addEventOptions); if (e.type === 'touchend') {