mirror of
https://github.com/Hopiu/fabric.js.git
synced 2026-03-16 22:10:32 +00:00
fixed multiple touchend (#4804)
This commit is contained in:
parent
808faa6d5f
commit
d105638e65
1 changed files with 10 additions and 9 deletions
|
|
@ -12,7 +12,8 @@
|
|||
},
|
||||
addListener = fabric.util.addListener,
|
||||
removeListener = fabric.util.removeListener,
|
||||
RIGHT_CLICK = 3, MIDDLE_CLICK = 2, LEFT_CLICK = 1;
|
||||
RIGHT_CLICK = 3, MIDDLE_CLICK = 2, LEFT_CLICK = 1,
|
||||
addEventOptions = { passive: false };
|
||||
|
||||
function checkClick(e, value) {
|
||||
return 'which' in e ? e.which === value : e.button === value - 1;
|
||||
|
|
@ -61,8 +62,8 @@
|
|||
addListener(this.upperCanvasEl, 'dragleave', this._onDragLeave);
|
||||
addListener(this.upperCanvasEl, 'drop', this._onDrop);
|
||||
// touch events
|
||||
addListener(this.upperCanvasEl, 'touchstart', this._onMouseDown, { passive: false });
|
||||
addListener(this.upperCanvasEl, 'touchmove', this._onMouseMove, { passive: false });
|
||||
addListener(this.upperCanvasEl, 'touchstart', this._onMouseDown, addEventOptions);
|
||||
addListener(this.upperCanvasEl, 'touchmove', this._onMouseMove, addEventOptions);
|
||||
|
||||
if (typeof eventjs !== 'undefined' && 'add' in eventjs) {
|
||||
eventjs.add(this.upperCanvasEl, 'gesture', this._onGesture);
|
||||
|
|
@ -250,11 +251,11 @@
|
|||
*/
|
||||
_onMouseDown: function (e) {
|
||||
this.__onMouseDown(e);
|
||||
addListener(fabric.document, 'touchend', this._onMouseUp, { passive: false });
|
||||
addListener(fabric.document, 'touchmove', this._onMouseMove, { passive: false });
|
||||
addListener(fabric.document, 'touchend', this._onMouseUp, addEventOptions);
|
||||
addListener(fabric.document, 'touchmove', this._onMouseMove, addEventOptions);
|
||||
|
||||
removeListener(this.upperCanvasEl, 'mousemove', this._onMouseMove);
|
||||
removeListener(this.upperCanvasEl, 'touchmove', this._onMouseMove);
|
||||
removeListener(this.upperCanvasEl, 'touchmove', this._onMouseMove, addEventOptions);
|
||||
|
||||
if (e.type === 'touchstart') {
|
||||
// Unbind mousedown to prevent double triggers from touch devices
|
||||
|
|
@ -274,13 +275,13 @@
|
|||
this.__onMouseUp(e);
|
||||
|
||||
removeListener(fabric.document, 'mouseup', this._onMouseUp);
|
||||
removeListener(fabric.document, 'touchend', this._onMouseUp);
|
||||
removeListener(fabric.document, 'touchend', this._onMouseUp, addEventOptions);
|
||||
|
||||
removeListener(fabric.document, 'mousemove', this._onMouseMove);
|
||||
removeListener(fabric.document, 'touchmove', this._onMouseMove);
|
||||
removeListener(fabric.document, 'touchmove', this._onMouseMove, addEventOptions);
|
||||
|
||||
addListener(this.upperCanvasEl, 'mousemove', this._onMouseMove);
|
||||
addListener(this.upperCanvasEl, 'touchmove', this._onMouseMove, { passive: false });
|
||||
addListener(this.upperCanvasEl, 'touchmove', this._onMouseMove, addEventOptions);
|
||||
|
||||
if (e.type === 'touchend') {
|
||||
// Wait 400ms before rebinding mousedown to prevent double triggers
|
||||
|
|
|
|||
Loading…
Reference in a new issue