diff --git a/package.json b/package.json index 9b935c9f2f6..e619ca55e15 100644 --- a/package.json +++ b/package.json @@ -61,7 +61,7 @@ }, "optionalDependencies": { "canvas": "^2.6.0", - "jsdom": "15.1.0" + "jsdom": "^15.1.0" }, "devDependencies": { "eslint": "4.18.x", diff --git a/src/brushes/pencil_brush.class.js b/src/brushes/pencil_brush.class.js index 69bb5a3b451..7c6568a2b97 100644 --- a/src/brushes/pencil_brush.class.js +++ b/src/brushes/pencil_brush.class.js @@ -37,7 +37,10 @@ * Inovoked on mouse down * @param {Object} pointer */ - onMouseDown: function(pointer) { + onMouseDown: function(pointer, options) { + if (!this.canvas._isMainEvent(options.e)) { + return; + } this._prepareForDrawing(pointer); // capture coordinates immediately // this allows to draw dots (when movement never occurs) @@ -49,7 +52,10 @@ * Inovoked on mouse move * @param {Object} pointer */ - onMouseMove: function(pointer) { + onMouseMove: function(pointer, options) { + if (!this.canvas._isMainEvent(options.e)) { + return; + } if (this._captureDrawingPath(pointer) && this._points.length > 1) { if (this.needsFullRender()) { // redraw curve @@ -75,9 +81,13 @@ /** * Invoked on mouse up */ - onMouseUp: function() { + onMouseUp: function(options) { + if (!this.canvas._isMainEvent(options.e)) { + return true; + } this.oldEnd = undefined; this._finalizeAndAddPath(); + return false; }, /** diff --git a/src/canvas.class.js b/src/canvas.class.js index bd26ac93766..0cf54d6e18b 100644 --- a/src/canvas.class.js +++ b/src/canvas.class.js @@ -1406,7 +1406,8 @@ height: height + 'px', left: 0, top: 0, - 'touch-action': this.allowTouchScrolling ? 'manipulation' : 'none' + 'touch-action': this.allowTouchScrolling ? 'manipulation' : 'none', + '-ms-touch-action': this.allowTouchScrolling ? 'manipulation' : 'none' }); element.width = width; element.height = height; @@ -1720,9 +1721,4 @@ fabric.Canvas[prop] = fabric.StaticCanvas[prop]; } } - - if (fabric.isTouchSupported) { - /** @ignore */ - fabric.Canvas.prototype._setCursorFromEvent = function() { }; - } })(); diff --git a/src/mixins/canvas_events.mixin.js b/src/mixins/canvas_events.mixin.js index c9500cccf37..c88ad098deb 100644 --- a/src/mixins/canvas_events.mixin.js +++ b/src/mixins/canvas_events.mixin.js @@ -16,7 +16,7 @@ addEventOptions = { passive: false }; function checkClick(e, value) { - return 'which' in e ? e.which === value : e.button === value - 1; + return e.button && (e.button === value - 1); } fabric.util.object.extend(fabric.Canvas.prototype, /** @lends fabric.Canvas.prototype */ { @@ -36,6 +36,13 @@ 'nw-resize' ], + /** + * Contains the id of the touch event that owns the fabric transform + * @type Number + * @private + */ + mainTouchId: null, + /** * Adds mouse listeners to canvas * @private @@ -49,9 +56,17 @@ this.addOrRemove(addListener, 'add'); }, + /** + * return an event prefix pointer or mouse. + * @private + */ + _getEventPrefix: function () { + return this.enablePointerEvents ? 'pointer' : 'mouse'; + }, + addOrRemove: function(functor, eventjsFunctor) { var canvasElement = this.upperCanvasEl, - eventTypePrefix = this.enablePointerEvents ? 'pointer' : 'mouse'; + eventTypePrefix = this._getEventPrefix(); functor(fabric.window, 'resize', this._onResize); functor(canvasElement, eventTypePrefix + 'down', this._onMouseDown); functor(canvasElement, eventTypePrefix + 'move', this._onMouseMove, addEventOptions); @@ -60,12 +75,13 @@ functor(canvasElement, 'wheel', this._onMouseWheel); functor(canvasElement, 'contextmenu', this._onContextMenu); functor(canvasElement, 'dblclick', this._onDoubleClick); - functor(canvasElement, 'touchstart', this._onMouseDown, addEventOptions); - functor(canvasElement, 'touchmove', this._onMouseMove, addEventOptions); functor(canvasElement, 'dragover', this._onDragOver); functor(canvasElement, 'dragenter', this._onDragEnter); functor(canvasElement, 'dragleave', this._onDragLeave); functor(canvasElement, 'drop', this._onDrop); + if (!this.enablePointerEvents) { + functor(canvasElement, 'touchstart', this._onTouchStart, addEventOptions); + } if (typeof eventjs !== 'undefined' && eventjsFunctor in eventjs) { eventjs[eventjsFunctor](canvasElement, 'gesture', this._onGesture); eventjs[eventjsFunctor](canvasElement, 'drag', this._onDrag); @@ -81,9 +97,9 @@ removeListeners: function() { this.addOrRemove(removeListener, 'remove'); // if you dispose on a mouseDown, before mouse up, you need to clean document to... - var eventTypePrefix = this.enablePointerEvents ? 'pointer' : 'mouse'; + var eventTypePrefix = this._getEventPrefix(); removeListener(fabric.document, eventTypePrefix + 'up', this._onMouseUp); - removeListener(fabric.document, 'touchend', this._onMouseUp, addEventOptions); + removeListener(fabric.document, 'touchend', this._onTouchEnd, addEventOptions); removeListener(fabric.document, eventTypePrefix + 'move', this._onMouseMove, addEventOptions); removeListener(fabric.document, 'touchmove', this._onMouseMove, addEventOptions); }, @@ -97,8 +113,10 @@ return; } this._onMouseDown = this._onMouseDown.bind(this); + this._onTouchStart = this._onTouchStart.bind(this); this._onMouseMove = this._onMouseMove.bind(this); this._onMouseUp = this._onMouseUp.bind(this); + this._onTouchEnd = this._onTouchEnd.bind(this); this._onResize = this._onResize.bind(this); this._onGesture = this._onGesture.bind(this); this._onDrag = this._onDrag.bind(this); @@ -238,29 +256,105 @@ this._resetTransformEventData(e); }, + /** + * Return a the id of an event. + * returns either the pointerId or the identifier or 0 for the mouse event + * @private + * @param {Event} evt Event object + */ + getPointerId: function(evt) { + var changedTouches = evt.changedTouches; + + if (changedTouches) { + return changedTouches[0] && changedTouches[0].identifier; + } + + if (this.enablePointerEvents) { + return evt.pointerId; + } + + return -1; + }, + + /** + * Determines if an event has the id of the event that is considered main + * @private + * @param {evt} event Event object + */ + _isMainEvent: function(evt) { + if (evt.isPrimary === true) { + return true; + } + if (evt.isPrimary === false) { + return false; + } + if (evt.type === 'touchend' && evt.touches.length === 0) { + return true; + } + if (evt.changedTouches) { + return evt.changedTouches[0].identifier === this.mainTouchId; + } + return true; + }, + /** * @private * @param {Event} e Event object fired on mousedown */ - _onMouseDown: function (e) { + _onTouchStart: function(e) { + e.preventDefault(); + if (this.mainTouchId === null) { + this.mainTouchId = this.getPointerId(e); + } this.__onMouseDown(e); this._resetTransformEventData(); - addListener(fabric.document, 'touchend', this._onMouseUp, addEventOptions); + var canvasElement = this.upperCanvasEl, + eventTypePrefix = this._getEventPrefix(); + addListener(fabric.document, 'touchend', this._onTouchEnd, addEventOptions); addListener(fabric.document, 'touchmove', this._onMouseMove, addEventOptions); + // Unbind mousedown to prevent double triggers from touch devices + removeListener(canvasElement, eventTypePrefix + 'down', this._onMouseDown); + }, + /** + * @private + * @param {Event} e Event object fired on mousedown + */ + _onMouseDown: function (e) { + this.__onMouseDown(e); + this._resetTransformEventData(); var canvasElement = this.upperCanvasEl, - eventTypePrefix = this.enablePointerEvents ? 'pointer' : 'mouse'; + eventTypePrefix = this._getEventPrefix(); removeListener(canvasElement, eventTypePrefix + 'move', this._onMouseMove, addEventOptions); - removeListener(canvasElement, 'touchmove', this._onMouseMove, addEventOptions); + addListener(fabric.document, eventTypePrefix + 'up', this._onMouseUp); + addListener(fabric.document, eventTypePrefix + 'move', this._onMouseMove, addEventOptions); + }, - if (e.type === 'touchstart') { - // Unbind mousedown to prevent double triggers from touch devices - removeListener(canvasElement, eventTypePrefix + 'down', this._onMouseDown); + /** + * @private + * @param {Event} e Event object fired on mousedown + */ + _onTouchEnd: function(e) { + if (e.touches.length > 0) { + // if there are still touches stop here + return; } - else { - addListener(fabric.document, eventTypePrefix + 'up', this._onMouseUp); - addListener(fabric.document, eventTypePrefix + 'move', this._onMouseMove, addEventOptions); + this.__onMouseUp(e); + this._resetTransformEventData(); + this.mainTouchId = null; + var eventTypePrefix = this._getEventPrefix(); + removeListener(fabric.document, 'touchend', this._onTouchEnd, addEventOptions); + removeListener(fabric.document, 'touchmove', this._onMouseMove, addEventOptions); + var _this = this; + if (this._willAddMouseDown) { + clearTimeout(this._willAddMouseDown); } + this._willAddMouseDown = setTimeout(function() { + // Wait 400ms before rebinding mousedown to prevent double triggers + // from touch devices + addListener(_this.upperCanvasEl, eventTypePrefix + 'down', _this._onMouseDown); + _this._willAddMouseDown = 0; + }, 400); }, /** @@ -271,24 +365,11 @@ this.__onMouseUp(e); this._resetTransformEventData(); var canvasElement = this.upperCanvasEl, - eventTypePrefix = this.enablePointerEvents ? 'pointer' : 'mouse'; - - removeListener(fabric.document, eventTypePrefix + 'up', this._onMouseUp); - removeListener(fabric.document, 'touchend', this._onMouseUp, addEventOptions); - - removeListener(fabric.document, eventTypePrefix + 'move', this._onMouseMove, addEventOptions); - removeListener(fabric.document, 'touchmove', this._onMouseMove, addEventOptions); - - addListener(canvasElement, eventTypePrefix + 'move', this._onMouseMove, addEventOptions); - addListener(canvasElement, 'touchmove', this._onMouseMove, addEventOptions); - - if (e.type === 'touchend') { - // Wait 400ms before rebinding mousedown to prevent double triggers - // from touch devices - var _this = this; - setTimeout(function() { - addListener(_this.upperCanvasEl, eventTypePrefix + 'down', _this._onMouseDown); - }, 400); + eventTypePrefix = this._getEventPrefix(); + if (this._isMainEvent(e)) { + removeListener(fabric.document, eventTypePrefix + 'up', this._onMouseUp); + removeListener(fabric.document, eventTypePrefix + 'move', this._onMouseMove, addEventOptions); + addListener(canvasElement, eventTypePrefix + 'move', this._onMouseMove, addEventOptions); } }, @@ -368,6 +449,9 @@ return; } + if (!this._isMainEvent(e)) { + return; + } if (transform) { this._finalizeCurrentTransform(e); shouldRender = transform.actionPerformed; @@ -556,12 +640,11 @@ * @param {Event} e Event object fired on mouseup */ _onMouseUpInDrawingMode: function(e) { - this._isCurrentlyDrawing = false; if (this.clipTo) { this.contextTop.restore(); } var pointer = this.getPointer(e); - this.freeDrawingBrush.onMouseUp({ e: e, pointer: pointer }); + this._isCurrentlyDrawing = this.freeDrawingBrush.onMouseUp({ e: e, pointer: pointer }); this._handleEvent(e, 'up'); }, @@ -597,6 +680,10 @@ return; } + if (!this._isMainEvent(e)) { + return; + } + // ignore if some object is being transformed at this moment if (this._currentTransform) { return; @@ -696,7 +783,8 @@ this._onMouseMoveInDrawingMode(e); return; } - if (typeof e.touches !== 'undefined' && e.touches.length > 1) { + + if (!this._isMainEvent(e)) { return; } @@ -928,7 +1016,6 @@ this.setCursor(this.defaultCursor); return false; } - var hoverCursor = target.hoverCursor || this.hoverCursor, activeSelection = this._activeObject && this._activeObject.type === 'activeSelection' ? this._activeObject : null, diff --git a/src/util/dom_event.js b/src/util/dom_event.js index 81b32e3c980..221717481d5 100644 --- a/src/util/dom_event.js +++ b/src/util/dom_event.js @@ -1,168 +1,6 @@ (function () { - - var unknown = 'unknown'; - - /* EVENT HANDLING */ - - function areHostMethods(object) { - var methodNames = Array.prototype.slice.call(arguments, 1), - t, i, len = methodNames.length; - for (i = 0; i < len; i++) { - t = typeof object[methodNames[i]]; - if (!(/^(?:function|object|unknown)$/).test(t)) { - return false; - } - } - return true; - } - - /** @ignore */ - var getElement, - setElement, - getUniqueId = (function () { - var uid = 0; - return function (element) { - return element.__uniqueID || (element.__uniqueID = 'uniqueID__' + uid++); - }; - })(); - - (function () { - var elements = { }; - /** @ignore */ - getElement = function (uid) { - return elements[uid]; - }; - /** @ignore */ - setElement = function (uid, element) { - elements[uid] = element; - }; - })(); - - function createListener(uid, handler) { - return { - handler: handler, - wrappedHandler: createWrappedHandler(uid, handler) - }; - } - - function createWrappedHandler(uid, handler) { - return function (e) { - handler.call(getElement(uid), e || fabric.window.event); - }; - } - - function createDispatcher(uid, eventName) { - return function (e) { - if (handlers[uid] && handlers[uid][eventName]) { - var handlersForEvent = handlers[uid][eventName]; - for (var i = 0, len = handlersForEvent.length; i < len; i++) { - handlersForEvent[i].call(this, e || fabric.window.event); - } - } - }; - } - - var shouldUseAddListenerRemoveListener = ( - areHostMethods(fabric.document.documentElement, 'addEventListener', 'removeEventListener') && - areHostMethods(fabric.window, 'addEventListener', 'removeEventListener')), - - shouldUseAttachEventDetachEvent = ( - areHostMethods(fabric.document.documentElement, 'attachEvent', 'detachEvent') && - areHostMethods(fabric.window, 'attachEvent', 'detachEvent')), - - // IE branch - listeners = { }, - - // DOM L0 branch - handlers = { }, - - addListener, removeListener; - - if (shouldUseAddListenerRemoveListener) { - /** @ignore */ - addListener = function (element, eventName, handler, options) { - // since ie10 or ie9 can use addEventListener but they do not support options, i need to check - element && element.addEventListener(eventName, handler, shouldUseAttachEventDetachEvent ? false : options); - }; - /** @ignore */ - removeListener = function (element, eventName, handler, options) { - element && element.removeEventListener(eventName, handler, shouldUseAttachEventDetachEvent ? false : options); - }; - } - - else if (shouldUseAttachEventDetachEvent) { - /** @ignore */ - addListener = function (element, eventName, handler) { - if (!element) { - return; - } - var uid = getUniqueId(element); - setElement(uid, element); - if (!listeners[uid]) { - listeners[uid] = { }; - } - if (!listeners[uid][eventName]) { - listeners[uid][eventName] = []; - - } - var listener = createListener(uid, handler); - listeners[uid][eventName].push(listener); - element.attachEvent('on' + eventName, listener.wrappedHandler); - }; - /** @ignore */ - removeListener = function (element, eventName, handler) { - if (!element) { - return; - } - var uid = getUniqueId(element), listener; - if (listeners[uid] && listeners[uid][eventName]) { - for (var i = 0, len = listeners[uid][eventName].length; i < len; i++) { - listener = listeners[uid][eventName][i]; - if (listener && listener.handler === handler) { - element.detachEvent('on' + eventName, listener.wrappedHandler); - listeners[uid][eventName][i] = null; - } - } - } - }; - } - else { - /** @ignore */ - addListener = function (element, eventName, handler) { - if (!element) { - return; - } - var uid = getUniqueId(element); - if (!handlers[uid]) { - handlers[uid] = { }; - } - if (!handlers[uid][eventName]) { - handlers[uid][eventName] = []; - var existingHandler = element['on' + eventName]; - if (existingHandler) { - handlers[uid][eventName].push(existingHandler); - } - element['on' + eventName] = createDispatcher(uid, eventName); - } - handlers[uid][eventName].push(handler); - }; - /** @ignore */ - removeListener = function (element, eventName, handler) { - if (!element) { - return; - } - var uid = getUniqueId(element); - if (handlers[uid] && handlers[uid][eventName]) { - var handlersForEvent = handlers[uid][eventName]; - for (var i = 0, len = handlersForEvent.length; i < len; i++) { - if (handlersForEvent[i] === handler) { - handlersForEvent.splice(i, 1); - } - } - } - }; - } - + // since ie10 or ie9 can use addEventListener but they do not support options, i need to check + var couldUseAttachEvent = !!fabric.document.createElement('div').attachEvent; /** * Adds an event listener to an element * @function @@ -171,7 +9,9 @@ * @param {String} eventName * @param {Function} handler */ - fabric.util.addListener = addListener; + fabric.util.addListener = function(element, eventName, handler, options) { + element && element.addEventListener(eventName, handler, couldUseAttachEvent ? false : options); + }; /** * Removes an event listener from an element @@ -181,58 +21,25 @@ * @param {String} eventName * @param {Function} handler */ - fabric.util.removeListener = removeListener; - - /** - * Cross-browser wrapper for getting event's coordinates - * @memberOf fabric.util - * @param {Event} event Event object - */ - function getPointer(event) { - event || (event = fabric.window.event); - - var element = event.target || - (typeof event.srcElement !== unknown ? event.srcElement : null), - - scroll = fabric.util.getScrollLeftTop(element); - return { - x: pointerX(event) + scroll.left, - y: pointerY(event) + scroll.top - }; - } - - var pointerX = function(event) { - return event.clientX; - }, - - pointerY = function(event) { - return event.clientY; - }; - - function _getPointer(event, pageProp, clientProp) { - var touchProp = event.type === 'touchend' ? 'changedTouches' : 'touches'; - var pointer, eventTouchProp = event[touchProp]; - - if (eventTouchProp && eventTouchProp[0]) { - pointer = eventTouchProp[0][clientProp]; - } - - if (typeof pointer === 'undefined') { - pointer = event[clientProp]; + fabric.util.removeListener = function(element, eventName, handler, options) { + element && element.removeEventListener(eventName, handler, couldUseAttachEvent ? false : options); + }; + + function getTouchInfo(event) { + var touchProp = event.changedTouches; + if (touchProp && touchProp[0]) { + return touchProp[0]; } - - return pointer; + return event; } - if (fabric.isTouchSupported) { - pointerX = function(event) { - return _getPointer(event, 'pageX', 'clientX'); - }; - pointerY = function(event) { - return _getPointer(event, 'pageY', 'clientY'); + fabric.util.getPointer = function(event) { + var element = event.target, + scroll = fabric.util.getScrollLeftTop(element), + _evt = getTouchInfo(event); + return { + x: _evt.clientX + scroll.left, + y: _evt.clientY + scroll.top }; - } - - fabric.util.getPointer = getPointer; - + }; })(); diff --git a/test/unit/brushes.js b/test/unit/brushes.js index 2d1f1080e05..70ce2bf750d 100644 --- a/test/unit/brushes.js +++ b/test/unit/brushes.js @@ -24,18 +24,18 @@ QUnit.test('fabric pencil brush draw point', function(assert) { var brush = new fabric.PencilBrush(canvas); var pointer = canvas.getPointer({ clientX: 10, clientY: 10}); - brush.onMouseDown(pointer); + brush.onMouseDown(pointer, { e: {} }); var pathData = brush.convertPointsToSVGPath(brush._points).join(''); assert.equal(pathData, 'M 9.999 10 L 10.001 10', 'path data create a small line that looks like a point'); }); QUnit.test('fabric pencil brush multiple points', function(assert) { var brush = new fabric.PencilBrush(canvas); var pointer = canvas.getPointer({ clientX: 10, clientY: 10}); - brush.onMouseDown(pointer); - brush.onMouseMove(pointer); - brush.onMouseMove(pointer); - brush.onMouseMove(pointer); - brush.onMouseMove(pointer); + brush.onMouseDown(pointer, { e: {} }); + brush.onMouseMove(pointer, { e: {} }); + brush.onMouseMove(pointer, { e: {} }); + brush.onMouseMove(pointer, { e: {} }); + brush.onMouseMove(pointer, { e: {} }); var pathData = brush.convertPointsToSVGPath(brush._points).join(''); assert.equal(pathData, 'M 9.999 10 L 10.001 10', 'path data create a small line that looks like a point'); assert.equal(brush._points.length, 2, 'concident points are discarded'); @@ -45,11 +45,11 @@ var pointer = canvas.getPointer({ clientX: 10, clientY: 10}); var pointer2 = canvas.getPointer({ clientX: 15, clientY: 15}); var pointer3 = canvas.getPointer({ clientX: 20, clientY: 20}); - brush.onMouseDown(pointer); - brush.onMouseMove(pointer2); - brush.onMouseMove(pointer3); - brush.onMouseMove(pointer2); - brush.onMouseMove(pointer3); + brush.onMouseDown(pointer, { e: {} }); + brush.onMouseMove(pointer2, { e: {} }); + brush.onMouseMove(pointer3, { e: {} }); + brush.onMouseMove(pointer2, { e: {} }); + brush.onMouseMove(pointer3, { e: {} }); var pathData = brush.convertPointsToSVGPath(brush._points).join(''); assert.equal(pathData, 'M 9.999 9.999 Q 10 10 12.5 12.5 Q 15 15 17.5 17.5 Q 20 20 17.5 17.5 Q 15 15 17.5 17.5 L 20.001 20.001', 'path data create a complex path'); assert.equal(brush._points.length, 6, 'concident points are discarded'); @@ -65,12 +65,12 @@ var pointer = canvas.getPointer({ clientX: 10, clientY: 10}); var pointer2 = canvas.getPointer({ clientX: 15, clientY: 15}); var pointer3 = canvas.getPointer({ clientX: 20, clientY: 20}); - brush.onMouseDown(pointer); - brush.onMouseMove(pointer2); - brush.onMouseMove(pointer3); - brush.onMouseMove(pointer2); - brush.onMouseMove(pointer3); - brush.onMouseUp(pointer3); + brush.onMouseDown(pointer, { e: {} }); + brush.onMouseMove(pointer2, { e: {} }); + brush.onMouseMove(pointer3, { e: {} }); + brush.onMouseMove(pointer2, { e: {} }); + brush.onMouseMove(pointer3, { e: {} }); + brush.onMouseUp({ e: {} }); assert.equal(fired, true, 'event is fired'); assert.ok(added instanceof fabric.Path, 'a path is added'); assert.ok(added.path.length, 6, 'path has 6 steps'); diff --git a/test/unit/canvas_events.js b/test/unit/canvas_events.js index cd1892458bb..369ed91ab2e 100644 --- a/test/unit/canvas_events.js +++ b/test/unit/canvas_events.js @@ -103,19 +103,19 @@ canvas.fireRightClick = false; canvas._currentTransform = false; canvas.isDrawingMode = false; - canvas.__onMouseDown({ which: 1, target: canvas.upperCanvasEl }); + canvas.__onMouseDown({ button: 0, target: canvas.upperCanvasEl }); assert.equal(clickCount, 1, 'mouse down fired'); clickCount = 0; - canvas.__onMouseDown({ which: 3, target: canvas.upperCanvasEl }); + canvas.__onMouseDown({ button: 2, target: canvas.upperCanvasEl }); assert.equal(clickCount, 0, 'rightclick did not fire a mouse:down event'); canvas.fireRightClick = true; - canvas.__onMouseDown({ which: 3, target: canvas.upperCanvasEl }); + canvas.__onMouseDown({ button: 2, target: canvas.upperCanvasEl }); assert.equal(clickCount, 1, 'rightclick did fire a mouse:down event'); clickCount = 0; - canvas.__onMouseDown({ which: 2, target: canvas.upperCanvasEl }); + canvas.__onMouseDown({ button: 1, target: canvas.upperCanvasEl }); assert.equal(clickCount, 0, 'middleClick did not fire a mouse:down event'); canvas.fireMiddleClick = true; - canvas.__onMouseDown({ which: 2, target: canvas.upperCanvasEl }); + canvas.__onMouseDown({ button: 1, target: canvas.upperCanvasEl }); assert.equal(clickCount, 1, 'middleClick did fire a mouse:down event'); }); diff --git a/test/visual/freedraw.js b/test/visual/freedraw.js index 3e5c7c44f06..97a93149c9f 100644 --- a/test/visual/freedraw.js +++ b/test/visual/freedraw.js @@ -34,15 +34,15 @@ else { visualTestLoop = window.visualTestLoop; } - + var options = { e: { pointerId: 1 } }; function pointDrawer(points, brush) { - brush.onMouseDown(points[0]); + brush.onMouseDown(points[0], options); for (var i = 1; i < points.length; i++) { points[i].x = parseFloat(points[i].x); points[i].y = parseFloat(points[i].y); - brush.onMouseMove(points[i]); + brush.onMouseMove(points[i], options); } - brush.onMouseUp(); + brush.onMouseUp(options); } var tests = [];