Skip to content

Commit

Permalink
passivefalseeverywhere (#3690)
Browse files Browse the repository at this point in the history
* passivefalseeverywhere

* Update canvas_events.mixin.js

* Update dom_event.js

* Update canvas.class.js
  • Loading branch information
asturur committed Feb 14, 2017
1 parent 91c851a commit 7ff1063
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
3 changes: 2 additions & 1 deletion src/canvas.class.js
Original file line number Diff line number Diff line change
Expand Up @@ -1312,7 +1312,8 @@
width: width + 'px',
height: height + 'px',
left: 0,
top: 0
top: 0,
'touch-action': 'none'
});
element.width = width;
element.height = height;
Expand Down
8 changes: 4 additions & 4 deletions src/mixins/canvas_events.mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@
addListener(this.upperCanvasEl, 'contextmenu', this._onContextMenu);

// touch events
addListener(this.upperCanvasEl, 'touchstart', this._onMouseDown);
addListener(this.upperCanvasEl, 'touchmove', this._onMouseMove);
addListener(this.upperCanvasEl, 'touchstart', this._onMouseDown, { passive: false });
addListener(this.upperCanvasEl, 'touchmove', this._onMouseMove, { passive: false });

if (typeof eventjs !== 'undefined' && 'add' in eventjs) {
eventjs.add(this.upperCanvasEl, 'gesture', this._onGesture);
Expand Down Expand Up @@ -199,7 +199,7 @@
_onMouseDown: function (e) {
this.__onMouseDown(e);

addListener(fabric.document, 'touchend', this._onMouseUp);
addListener(fabric.document, 'touchend', this._onMouseUp, { passive: false });
addListener(fabric.document, 'touchmove', this._onMouseMove, { passive: false });

removeListener(this.upperCanvasEl, 'mousemove', this._onMouseMove);
Expand Down Expand Up @@ -229,7 +229,7 @@
removeListener(fabric.document, 'touchmove', this._onMouseMove);

addListener(this.upperCanvasEl, 'mousemove', this._onMouseMove);
addListener(this.upperCanvasEl, 'touchmove', this._onMouseMove);
addListener(this.upperCanvasEl, 'touchmove', this._onMouseMove, { passive: false });

if (e.type === 'touchend') {
// Wait 400ms before rebinding mousedown to prevent double triggers
Expand Down
9 changes: 5 additions & 4 deletions src/util/dom_event.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,13 @@

if (shouldUseAddListenerRemoveListener) {
/** @ignore */
addListener = function (element, eventName, handler) {
element.addEventListener(eventName, handler, false);
addListener = function (element, eventName, handler, options) {
// since ie10 or ie9 can use addEventListener but they do not support options, i need to check
element.addEventListener(eventName, handler, shouldUseAttachEventDetachEvent ? false : options);
};
/** @ignore */
removeListener = function (element, eventName, handler) {
element.removeEventListener(eventName, handler, false);
removeListener = function (element, eventName, handler, options) {
element.removeEventListener(eventName, handler, shouldUseAttachEventDetachEvent ? false : options);
};
}

Expand Down

0 comments on commit 7ff1063

Please sign in to comment.