From 537eeb59cab3aa87b6132584b00b6ad936c7f85e Mon Sep 17 00:00:00 2001 From: Andrea Bogazzi Date: Sat, 9 Jan 2021 12:56:07 +0100 Subject: [PATCH 01/13] remove control check from pixel find --- src/canvas.class.js | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/src/canvas.class.js b/src/canvas.class.js index 1d346ee88e4..3826dec6544 100644 --- a/src/canvas.class.js +++ b/src/canvas.class.js @@ -497,13 +497,6 @@ target.render(ctx); ctx.restore(); - target === this._activeObject && target._renderControls(ctx, { - hasBorders: false, - transparentCorners: false - }, { - hasBorders: false, - }); - target.selectionBackgroundColor = originalColor; var isTransparent = fabric.util.isTransparent( @@ -765,18 +758,19 @@ activeObject = this._activeObject, aObjects = this.getActiveObjects(), activeTarget, activeTargetSubs, - isTouch = isTouchEvent(e); + isTouch = isTouchEvent(e), + shouldLookForActive = (aObjects.length > 1 && !skipGroup) || aObjects.length === 1; // first check current group (if one exists) // active group does not check sub targets like normal groups. // if active group just exits. this.targets = []; - if (aObjects.length > 1 && !skipGroup && activeObject === this._searchPossibleTargets([activeObject], pointer)) { + // if we hit the corner of an activeObject, let's return that. + if (shouldLookForActive && activeObject._findTargetCorner(pointer, isTouch)) { return activeObject; } - // if we hit the corner of an activeObject, let's return that. - if (aObjects.length === 1 && activeObject._findTargetCorner(pointer, isTouch)) { + if (aObjects.length > 1 && !skipGroup && activeObject === this._searchPossibleTargets([activeObject], pointer)) { return activeObject; } if (aObjects.length === 1 && @@ -812,7 +806,7 @@ obj.evented && // http://www.geog.ubc.ca/courses/klink/gis.notes/ncgia/u32.html // http://idav.ucdavis.edu/~okreylos/TAship/Spring2000/PointInPolygon.html - (obj.containsPoint(pointer) || !!obj._findTargetCorner(pointer)) + obj.containsPoint(pointer) ) { if ((this.perPixelTargetFind || obj.perPixelTargetFind) && !obj.isEditing) { var isTransparent = this.isTargetTransparent(obj, globalPointer.x, globalPointer.y); From e3bd1de824d6c4391e077d8418a2472f451e7b20 Mon Sep 17 00:00:00 2001 From: Andrea Bogazzi Date: Sun, 10 Jan 2021 19:01:34 +0100 Subject: [PATCH 02/13] save --- test/unit/canvas.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/unit/canvas.js b/test/unit/canvas.js index d1fba56d96e..4d3be49558c 100644 --- a/test/unit/canvas.js +++ b/test/unit/canvas.js @@ -2452,9 +2452,9 @@ assert.equal(canvas.isTargetTransparent(rect, 1, 1), false, 'opaque on 1,1'); assert.equal(canvas.isTargetTransparent(rect, 2, 2), false, 'opaque on 2,2'); assert.equal(canvas.isTargetTransparent(rect, 3, 3), false, 'opaque on 3,3'); - assert.equal(canvas.isTargetTransparent(rect, 4, 4), false, 'opaque on 4,4'); - assert.equal(canvas.isTargetTransparent(rect, 5, 5), false, 'opaque on 5, 5'); - assert.equal(canvas.isTargetTransparent(rect, 6, 6), false, 'opaque on 6, 6'); + assert.equal(canvas.isTargetTransparent(rect, 4, 4), true, 'transparent on 4,4'); + assert.equal(canvas.isTargetTransparent(rect, 5, 5), true, 'transparent on 5, 5'); + assert.equal(canvas.isTargetTransparent(rect, 6, 6), true, 'transparent on 6, 6'); assert.equal(canvas.isTargetTransparent(rect, 7, 7), true, 'transparent on 7, 7'); assert.equal(canvas.isTargetTransparent(rect, 8, 8), true, 'transparent on 8, 8'); assert.equal(canvas.isTargetTransparent(rect, 9, 9), true, 'transparent on 9, 9'); From b9fefeb6364783ca6899a46e102b359e7d8c5541 Mon Sep 17 00:00:00 2001 From: Andrea Bogazzi Date: Sat, 30 Jan 2021 15:49:51 +0100 Subject: [PATCH 03/13] changed names --- .github/workflows/browser-chrome.yml | 2 +- .github/workflows/browser-firefox.yml | 3 +-- .github/workflows/linting.yml | 2 +- .github/workflows/node-unit-tests.yml | 2 +- .github/workflows/visual-node.yml | 2 +- .github/workflows/visual-test-chrome.yml | 2 +- .github/workflows/visual-test-firefox.yml | 2 +- package.json | 1 - 8 files changed, 7 insertions(+), 9 deletions(-) diff --git a/.github/workflows/browser-chrome.yml b/.github/workflows/browser-chrome.yml index 0b8c6180a00..6d3eec100de 100644 --- a/.github/workflows/browser-chrome.yml +++ b/.github/workflows/browser-chrome.yml @@ -9,7 +9,7 @@ on: branches: [ master ] jobs: - build: + chrome-tests: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 diff --git a/.github/workflows/browser-firefox.yml b/.github/workflows/browser-firefox.yml index e428d6bbc2c..a05d4131031 100644 --- a/.github/workflows/browser-firefox.yml +++ b/.github/workflows/browser-firefox.yml @@ -9,7 +9,7 @@ on: branches: [ master ] jobs: - build: + firefox-tests: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 @@ -23,4 +23,3 @@ jobs: uses: GabrielBB/xvfb-action@v1 with: run: npm run testem:ci -- --port 8080 -f testem.json -l Firefox - diff --git a/.github/workflows/linting.yml b/.github/workflows/linting.yml index 4c78b696587..e5491157fa4 100644 --- a/.github/workflows/linting.yml +++ b/.github/workflows/linting.yml @@ -8,7 +8,7 @@ on: branches: [ master ] jobs: - build: + lint: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 diff --git a/.github/workflows/node-unit-tests.yml b/.github/workflows/node-unit-tests.yml index dce6a431dc2..db1288b1abd 100644 --- a/.github/workflows/node-unit-tests.yml +++ b/.github/workflows/node-unit-tests.yml @@ -10,7 +10,7 @@ on: branches: [ master ] jobs: - build: + node-unit-tests: runs-on: ubuntu-latest strategy: fail-fast: false diff --git a/.github/workflows/visual-node.yml b/.github/workflows/visual-node.yml index 31b41b8484a..9536d682961 100644 --- a/.github/workflows/visual-node.yml +++ b/.github/workflows/visual-node.yml @@ -10,7 +10,7 @@ on: branches: [ master ] jobs: - build: + node-visual-tests: runs-on: ubuntu-latest strategy: fail-fast: false diff --git a/.github/workflows/visual-test-chrome.yml b/.github/workflows/visual-test-chrome.yml index 14bf6690115..aacd9cc6a03 100644 --- a/.github/workflows/visual-test-chrome.yml +++ b/.github/workflows/visual-test-chrome.yml @@ -9,7 +9,7 @@ on: branches: [ master ] jobs: - build: + chrome-visual-tests: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 diff --git a/.github/workflows/visual-test-firefox.yml b/.github/workflows/visual-test-firefox.yml index 54b3cd7e77c..23050837c9c 100644 --- a/.github/workflows/visual-test-firefox.yml +++ b/.github/workflows/visual-test-firefox.yml @@ -9,7 +9,7 @@ on: branches: [ master ] jobs: - build: + firefox-visual-tests: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 diff --git a/package.json b/package.json index 1608f44c272..9a9f4a9b7b3 100644 --- a/package.json +++ b/package.json @@ -58,7 +58,6 @@ "export_tests_to_site": "cp test/unit/*.js ../fabricjs.com/test/unit && cp -r test/visual/* ../fabricjs.com/test/visual && cp -r test/fixtures/* ../fabricjs.com/test/fixtures && cp -r test/lib/* ../fabricjs.com/test/lib", "all": "npm run build && npm run test && npm run test:visual && npm run lint && npm run lint_tests && npm run export_dist_to_site && npm run export_tests_to_site", "testem": "testem .", - "testem:visual": "testem --file testem-visual.json", "testem:ci": "testem ci" }, "optionalDependencies": { From fbae23272387b5629234c101bc6b321682016119 Mon Sep 17 00:00:00 2001 From: Andrea Bogazzi Date: Sat, 30 Jan 2021 16:19:23 +0100 Subject: [PATCH 04/13] coverage experiment --- .github/workflows/build.js.yml | 27 ++++++++- .github/workflows/node-unit-tests.yml | 2 +- .github/workflows/visual-node.yml | 2 +- dist/fabric.js | 84 +++++++++++++++++++-------- package.json | 6 +- 5 files changed, 93 insertions(+), 28 deletions(-) diff --git a/.github/workflows/build.js.yml b/.github/workflows/build.js.yml index 82539bed99d..9d154100cc4 100644 --- a/.github/workflows/build.js.yml +++ b/.github/workflows/build.js.yml @@ -10,13 +10,36 @@ on: jobs: build: - runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - name: Uglyfied build uses: actions/setup-node@v1 with: - node-version: 14.x + node-version: 12.x - run: npm install uglify-js@3.3.x - run: npm run build + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Linting + uses: actions/setup-node@v1 + with: + node-version: 12.x + - run: npm install eslint@4.7.x + - run: npm run lint + coverage: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Coverage report + uses: actions/setup-node@v1 + with: + node-version: 12.x + - run: npm ci + - run: npm run coverage + - uses: romeovs/lcov-reporter-action@v0.2.16 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + lcov-file: ./coverage/lcov.info diff --git a/.github/workflows/node-unit-tests.yml b/.github/workflows/node-unit-tests.yml index db1288b1abd..9b5dacb8ccd 100644 --- a/.github/workflows/node-unit-tests.yml +++ b/.github/workflows/node-unit-tests.yml @@ -15,7 +15,7 @@ jobs: strategy: fail-fast: false matrix: - node-version: [12.x, 14.x, 15.x] + node-version: [14.x, 15.x] # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ steps: - uses: actions/checkout@v2 diff --git a/.github/workflows/visual-node.yml b/.github/workflows/visual-node.yml index 9536d682961..271f965f5db 100644 --- a/.github/workflows/visual-node.yml +++ b/.github/workflows/visual-node.yml @@ -15,7 +15,7 @@ jobs: strategy: fail-fast: false matrix: - node-version: [12.x, 14.x, 15.x] + node-version: [14.x, 15.x] # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ steps: - uses: actions/checkout@v2 diff --git a/dist/fabric.js b/dist/fabric.js index 2ae94e2eb01..8185d3c3288 100644 --- a/dist/fabric.js +++ b/dist/fabric.js @@ -6492,7 +6492,7 @@ fabric.ElementsParser = function(elements, callback, options, reviver, parsingOp * @return {Boolean} true if one flip, but not two. */ function targetHasOneFlip(target) { - return (target.flipX && !target.flipY) || (!target.flipX && target.flipY); + return target.flipX !== target.flipY; } /** @@ -10226,6 +10226,15 @@ fabric.BaseBrush = fabric.util.createClass(/** @lends fabric.BaseBrush.prototype */ strokeDashArray: null, + /** + * When `true`, the free drawing is limited to the whiteboard size. Default to false. + * @type Boolean + * @default false + */ + + limitedToCanvasSize: false, + + /** * Sets brush styles * @private @@ -10290,6 +10299,15 @@ fabric.BaseBrush = fabric.util.createClass(/** @lends fabric.BaseBrush.prototype ctx.shadowColor = ''; ctx.shadowBlur = ctx.shadowOffsetX = ctx.shadowOffsetY = 0; + }, + + /** + * Check is pointer is outside canvas boundaries + * @param {Object} pointer + * @private + */ + _isOutSideCanvas: function(pointer) { + return pointer.x < 0 || pointer.x > this.canvas.getWidth() || pointer.y < 0 || pointer.y > this.canvas.getHeight(); } }); @@ -10352,6 +10370,9 @@ fabric.BaseBrush = fabric.util.createClass(/** @lends fabric.BaseBrush.prototype if (!this.canvas._isMainEvent(options.e)) { return; } + if (this.limitedToCanvasSize === true && this._isOutSideCanvas(pointer)) { + return; + } if (this._captureDrawingPath(pointer) && this._points.length > 1) { if (this.needsFullRender()) { // redraw curve @@ -10661,6 +10682,9 @@ fabric.CircleBrush = fabric.util.createClass(fabric.BaseBrush, /** @lends fabric * @param {Object} pointer */ onMouseMove: function(pointer) { + if (this.limitedToCanvasSize === true && this._isOutSideCanvas(pointer)) { + return; + } if (this.needsFullRender()) { this.canvas.clearContext(this.canvas.contextTop); this.addPoint(pointer); @@ -10808,6 +10832,9 @@ fabric.SprayBrush = fabric.util.createClass( fabric.BaseBrush, /** @lends fabric * @param {Object} pointer */ onMouseMove: function(pointer) { + if (this.limitedToCanvasSize === true && this._isOutSideCanvas(pointer)) { + return; + } this.addSprayChunk(pointer); this.render(this.sprayChunkPoints); }, @@ -11510,13 +11537,6 @@ fabric.PatternBrush = fabric.util.createClass(fabric.PencilBrush, /** @lends fab target.render(ctx); ctx.restore(); - target === this._activeObject && target._renderControls(ctx, { - hasBorders: false, - transparentCorners: false - }, { - hasBorders: false, - }); - target.selectionBackgroundColor = originalColor; var isTransparent = fabric.util.isTransparent( @@ -11778,18 +11798,19 @@ fabric.PatternBrush = fabric.util.createClass(fabric.PencilBrush, /** @lends fab activeObject = this._activeObject, aObjects = this.getActiveObjects(), activeTarget, activeTargetSubs, - isTouch = isTouchEvent(e); + isTouch = isTouchEvent(e), + shouldLookForActive = (aObjects.length > 1 && !skipGroup) || aObjects.length === 1; // first check current group (if one exists) // active group does not check sub targets like normal groups. // if active group just exits. this.targets = []; - if (aObjects.length > 1 && !skipGroup && activeObject === this._searchPossibleTargets([activeObject], pointer)) { + // if we hit the corner of an activeObject, let's return that. + if (shouldLookForActive && activeObject._findTargetCorner(pointer, isTouch)) { return activeObject; } - // if we hit the corner of an activeObject, let's return that. - if (aObjects.length === 1 && activeObject._findTargetCorner(pointer, isTouch)) { + if (aObjects.length > 1 && !skipGroup && activeObject === this._searchPossibleTargets([activeObject], pointer)) { return activeObject; } if (aObjects.length === 1 && @@ -11825,7 +11846,7 @@ fabric.PatternBrush = fabric.util.createClass(fabric.PencilBrush, /** @lends fab obj.evented && // http://www.geog.ubc.ca/courses/klink/gis.notes/ncgia/u32.html // http://idav.ucdavis.edu/~okreylos/TAship/Spring2000/PointInPolygon.html - (obj.containsPoint(pointer) || !!obj._findTargetCorner(pointer)) + obj.containsPoint(pointer) ) { if ((this.perPixelTargetFind || obj.perPixelTargetFind) && !obj.isEditing) { var isTransparent = this.isTargetTransparent(obj, globalPointer.x, globalPointer.y); @@ -12783,15 +12804,21 @@ fabric.PatternBrush = fabric.util.createClass(fabric.PencilBrush, /** @lends fab } } if (target) { - var corner = target._findTargetCorner( - this.getPointer(e, true), - fabric.util.isTouchEvent(e) - ); - var control = target.controls[corner], - mouseUpHandler = control && control.getMouseUpHandler(e, target, control); - if (mouseUpHandler) { - var pointer = this.getPointer(e); - mouseUpHandler(e, transform, pointer.x, pointer.y); + if (target.selectable && target !== this._activeObject && target.activeOn === 'up') { + this.setActiveObject(target, e); + shouldRender = true; + } + else { + var corner = target._findTargetCorner( + this.getPointer(e, true), + fabric.util.isTouchEvent(e) + ); + var control = target.controls[corner], + mouseUpHandler = control && control.getMouseUpHandler(e, target, control); + if (mouseUpHandler) { + var pointer = this.getPointer(e); + mouseUpHandler(e, transform, pointer.x, pointer.y); + } } target.isMoving = false; } @@ -13047,7 +13074,7 @@ fabric.PatternBrush = fabric.util.createClass(fabric.PencilBrush, /** @lends fab if (target) { var alreadySelected = target === this._activeObject; - if (target.selectable) { + if (target.selectable && target.activeOn === 'down') { this.setActiveObject(target, e); } var corner = target._findTargetCorner( @@ -14418,6 +14445,17 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @lends fabric.Stati */ paintFirst: 'fill', + /** + * When 'down', object is set to active on mousedown/touchstart + * When 'up', object is set to active on mouseup/touchend + * Experimental. Let's see if this breaks anything before supporting officially + * @private + * since 4.4.0 + * @type String + * @default 'down' + */ + activeOn: 'down', + /** * List of properties to consider when checking if state * of an object is changed (fabric.Object#hasStateChanged) diff --git a/package.json b/package.json index 9a9f4a9b7b3..0f859d73753 100644 --- a/package.json +++ b/package.json @@ -47,7 +47,11 @@ "build_with_gestures": "node build.js modules=ALL exclude=accessors", "build_export": "npm run build:fast && npm run export_dist_to_site", "test:single": "qunit test/node_test_setup.js test/lib", - "test": "nyc qunit test/node_test_setup.js test/lib test/unit", + "test:coverage": "nyc --silent qunit test/node_test_setup.js test/lib test/unit", + "test:visual:coverage": "nyc --silent --no-clean qunit test/node_test_setup.js test/lib test/visual", + "cover:report": "nyc report --reporter=lcov --reporter=text", + "coverage": "npm run test:coverage && npm run test:visual:coverage && npm run cover:report", + "test": "qunit test/node_test_setup.js test/lib test/unit", "test:visual": "qunit test/node_test_setup.js test/lib test/visual", "test:visual:single": "qunit test/node_test_setup.js test/lib", "test:all": "npm run test && npm run test:visual", From 101efccc99eed08607e1adc3b40083775f97cb05 Mon Sep 17 00:00:00 2001 From: Andrea Bogazzi Date: Sat, 30 Jan 2021 16:19:44 +0100 Subject: [PATCH 05/13] no master --- dist/fabric.js | 84 ++++++++++++++------------------------------------ 1 file changed, 23 insertions(+), 61 deletions(-) diff --git a/dist/fabric.js b/dist/fabric.js index 8185d3c3288..2ae94e2eb01 100644 --- a/dist/fabric.js +++ b/dist/fabric.js @@ -6492,7 +6492,7 @@ fabric.ElementsParser = function(elements, callback, options, reviver, parsingOp * @return {Boolean} true if one flip, but not two. */ function targetHasOneFlip(target) { - return target.flipX !== target.flipY; + return (target.flipX && !target.flipY) || (!target.flipX && target.flipY); } /** @@ -10226,15 +10226,6 @@ fabric.BaseBrush = fabric.util.createClass(/** @lends fabric.BaseBrush.prototype */ strokeDashArray: null, - /** - * When `true`, the free drawing is limited to the whiteboard size. Default to false. - * @type Boolean - * @default false - */ - - limitedToCanvasSize: false, - - /** * Sets brush styles * @private @@ -10299,15 +10290,6 @@ fabric.BaseBrush = fabric.util.createClass(/** @lends fabric.BaseBrush.prototype ctx.shadowColor = ''; ctx.shadowBlur = ctx.shadowOffsetX = ctx.shadowOffsetY = 0; - }, - - /** - * Check is pointer is outside canvas boundaries - * @param {Object} pointer - * @private - */ - _isOutSideCanvas: function(pointer) { - return pointer.x < 0 || pointer.x > this.canvas.getWidth() || pointer.y < 0 || pointer.y > this.canvas.getHeight(); } }); @@ -10370,9 +10352,6 @@ fabric.BaseBrush = fabric.util.createClass(/** @lends fabric.BaseBrush.prototype if (!this.canvas._isMainEvent(options.e)) { return; } - if (this.limitedToCanvasSize === true && this._isOutSideCanvas(pointer)) { - return; - } if (this._captureDrawingPath(pointer) && this._points.length > 1) { if (this.needsFullRender()) { // redraw curve @@ -10682,9 +10661,6 @@ fabric.CircleBrush = fabric.util.createClass(fabric.BaseBrush, /** @lends fabric * @param {Object} pointer */ onMouseMove: function(pointer) { - if (this.limitedToCanvasSize === true && this._isOutSideCanvas(pointer)) { - return; - } if (this.needsFullRender()) { this.canvas.clearContext(this.canvas.contextTop); this.addPoint(pointer); @@ -10832,9 +10808,6 @@ fabric.SprayBrush = fabric.util.createClass( fabric.BaseBrush, /** @lends fabric * @param {Object} pointer */ onMouseMove: function(pointer) { - if (this.limitedToCanvasSize === true && this._isOutSideCanvas(pointer)) { - return; - } this.addSprayChunk(pointer); this.render(this.sprayChunkPoints); }, @@ -11537,6 +11510,13 @@ fabric.PatternBrush = fabric.util.createClass(fabric.PencilBrush, /** @lends fab target.render(ctx); ctx.restore(); + target === this._activeObject && target._renderControls(ctx, { + hasBorders: false, + transparentCorners: false + }, { + hasBorders: false, + }); + target.selectionBackgroundColor = originalColor; var isTransparent = fabric.util.isTransparent( @@ -11798,19 +11778,18 @@ fabric.PatternBrush = fabric.util.createClass(fabric.PencilBrush, /** @lends fab activeObject = this._activeObject, aObjects = this.getActiveObjects(), activeTarget, activeTargetSubs, - isTouch = isTouchEvent(e), - shouldLookForActive = (aObjects.length > 1 && !skipGroup) || aObjects.length === 1; + isTouch = isTouchEvent(e); // first check current group (if one exists) // active group does not check sub targets like normal groups. // if active group just exits. this.targets = []; - // if we hit the corner of an activeObject, let's return that. - if (shouldLookForActive && activeObject._findTargetCorner(pointer, isTouch)) { + if (aObjects.length > 1 && !skipGroup && activeObject === this._searchPossibleTargets([activeObject], pointer)) { return activeObject; } - if (aObjects.length > 1 && !skipGroup && activeObject === this._searchPossibleTargets([activeObject], pointer)) { + // if we hit the corner of an activeObject, let's return that. + if (aObjects.length === 1 && activeObject._findTargetCorner(pointer, isTouch)) { return activeObject; } if (aObjects.length === 1 && @@ -11846,7 +11825,7 @@ fabric.PatternBrush = fabric.util.createClass(fabric.PencilBrush, /** @lends fab obj.evented && // http://www.geog.ubc.ca/courses/klink/gis.notes/ncgia/u32.html // http://idav.ucdavis.edu/~okreylos/TAship/Spring2000/PointInPolygon.html - obj.containsPoint(pointer) + (obj.containsPoint(pointer) || !!obj._findTargetCorner(pointer)) ) { if ((this.perPixelTargetFind || obj.perPixelTargetFind) && !obj.isEditing) { var isTransparent = this.isTargetTransparent(obj, globalPointer.x, globalPointer.y); @@ -12804,21 +12783,15 @@ fabric.PatternBrush = fabric.util.createClass(fabric.PencilBrush, /** @lends fab } } if (target) { - if (target.selectable && target !== this._activeObject && target.activeOn === 'up') { - this.setActiveObject(target, e); - shouldRender = true; - } - else { - var corner = target._findTargetCorner( - this.getPointer(e, true), - fabric.util.isTouchEvent(e) - ); - var control = target.controls[corner], - mouseUpHandler = control && control.getMouseUpHandler(e, target, control); - if (mouseUpHandler) { - var pointer = this.getPointer(e); - mouseUpHandler(e, transform, pointer.x, pointer.y); - } + var corner = target._findTargetCorner( + this.getPointer(e, true), + fabric.util.isTouchEvent(e) + ); + var control = target.controls[corner], + mouseUpHandler = control && control.getMouseUpHandler(e, target, control); + if (mouseUpHandler) { + var pointer = this.getPointer(e); + mouseUpHandler(e, transform, pointer.x, pointer.y); } target.isMoving = false; } @@ -13074,7 +13047,7 @@ fabric.PatternBrush = fabric.util.createClass(fabric.PencilBrush, /** @lends fab if (target) { var alreadySelected = target === this._activeObject; - if (target.selectable && target.activeOn === 'down') { + if (target.selectable) { this.setActiveObject(target, e); } var corner = target._findTargetCorner( @@ -14445,17 +14418,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @lends fabric.Stati */ paintFirst: 'fill', - /** - * When 'down', object is set to active on mousedown/touchstart - * When 'up', object is set to active on mouseup/touchend - * Experimental. Let's see if this breaks anything before supporting officially - * @private - * since 4.4.0 - * @type String - * @default 'down' - */ - activeOn: 'down', - /** * List of properties to consider when checking if state * of an object is changed (fabric.Object#hasStateChanged) From ade5424f22ddbef17594aeda0ecfb7153176f894 Mon Sep 17 00:00:00 2001 From: Andrea Bogazzi Date: Sat, 30 Jan 2021 16:31:33 +0100 Subject: [PATCH 06/13] beter --- .github/workflows/build.js.yml | 2 +- .github/workflows/linting.yml | 20 -------------------- test/unit/canvas.js | 6 +++--- 3 files changed, 4 insertions(+), 24 deletions(-) delete mode 100644 .github/workflows/linting.yml diff --git a/.github/workflows/build.js.yml b/.github/workflows/build.js.yml index 9d154100cc4..5213a225b7b 100644 --- a/.github/workflows/build.js.yml +++ b/.github/workflows/build.js.yml @@ -1,6 +1,6 @@ # This workflow will install Uglify and verify that fabric can be build with it -name: Building with uglify +name: Pr quality check on: push: diff --git a/.github/workflows/linting.yml b/.github/workflows/linting.yml deleted file mode 100644 index e5491157fa4..00000000000 --- a/.github/workflows/linting.yml +++ /dev/null @@ -1,20 +0,0 @@ -# This workflow will install eslint and lint the code. -name: Linting - -on: - push: - branches: [ master ] - pull_request: - branches: [ master ] - -jobs: - lint: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: Linting - uses: actions/setup-node@v1 - with: - node-version: 14.x - - run: npm install eslint@4.7.x - - run: npm run lint diff --git a/test/unit/canvas.js b/test/unit/canvas.js index 4d3be49558c..d1fba56d96e 100644 --- a/test/unit/canvas.js +++ b/test/unit/canvas.js @@ -2452,9 +2452,9 @@ assert.equal(canvas.isTargetTransparent(rect, 1, 1), false, 'opaque on 1,1'); assert.equal(canvas.isTargetTransparent(rect, 2, 2), false, 'opaque on 2,2'); assert.equal(canvas.isTargetTransparent(rect, 3, 3), false, 'opaque on 3,3'); - assert.equal(canvas.isTargetTransparent(rect, 4, 4), true, 'transparent on 4,4'); - assert.equal(canvas.isTargetTransparent(rect, 5, 5), true, 'transparent on 5, 5'); - assert.equal(canvas.isTargetTransparent(rect, 6, 6), true, 'transparent on 6, 6'); + assert.equal(canvas.isTargetTransparent(rect, 4, 4), false, 'opaque on 4,4'); + assert.equal(canvas.isTargetTransparent(rect, 5, 5), false, 'opaque on 5, 5'); + assert.equal(canvas.isTargetTransparent(rect, 6, 6), false, 'opaque on 6, 6'); assert.equal(canvas.isTargetTransparent(rect, 7, 7), true, 'transparent on 7, 7'); assert.equal(canvas.isTargetTransparent(rect, 8, 8), true, 'transparent on 8, 8'); assert.equal(canvas.isTargetTransparent(rect, 9, 9), true, 'transparent on 9, 9'); From d18713dc93b4a63012e430a59694c4759618ce51 Mon Sep 17 00:00:00 2001 From: Andrea Bogazzi Date: Sat, 30 Jan 2021 16:43:19 +0100 Subject: [PATCH 07/13] fixed tests --- .github/workflows/build.js.yml | 1 + test/unit/canvas.js | 26 +++++++++++++------------- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/.github/workflows/build.js.yml b/.github/workflows/build.js.yml index 5213a225b7b..1cae7781c63 100644 --- a/.github/workflows/build.js.yml +++ b/.github/workflows/build.js.yml @@ -38,6 +38,7 @@ jobs: with: node-version: 12.x - run: npm ci + - run: npm build:fast - run: npm run coverage - uses: romeovs/lcov-reporter-action@v0.2.16 with: diff --git a/test/unit/canvas.js b/test/unit/canvas.js index d1fba56d96e..1594d29ee53 100644 --- a/test/unit/canvas.js +++ b/test/unit/canvas.js @@ -2452,9 +2452,9 @@ assert.equal(canvas.isTargetTransparent(rect, 1, 1), false, 'opaque on 1,1'); assert.equal(canvas.isTargetTransparent(rect, 2, 2), false, 'opaque on 2,2'); assert.equal(canvas.isTargetTransparent(rect, 3, 3), false, 'opaque on 3,3'); - assert.equal(canvas.isTargetTransparent(rect, 4, 4), false, 'opaque on 4,4'); - assert.equal(canvas.isTargetTransparent(rect, 5, 5), false, 'opaque on 5, 5'); - assert.equal(canvas.isTargetTransparent(rect, 6, 6), false, 'opaque on 6, 6'); + assert.equal(canvas.isTargetTransparent(rect, 4, 4), true, 'transparent on 4,4'); + assert.equal(canvas.isTargetTransparent(rect, 5, 5), true, 'transparent on 5, 5'); + assert.equal(canvas.isTargetTransparent(rect, 6, 6), true, 'transparent on 6, 6'); assert.equal(canvas.isTargetTransparent(rect, 7, 7), true, 'transparent on 7, 7'); assert.equal(canvas.isTargetTransparent(rect, 8, 8), true, 'transparent on 8, 8'); assert.equal(canvas.isTargetTransparent(rect, 9, 9), true, 'transparent on 9, 9'); @@ -2465,20 +2465,20 @@ assert.equal(canvas.isTargetTransparent(rect, 14, 14), true, 'transparent 14, 14'); assert.equal(canvas.isTargetTransparent(rect, 15, 15), true, 'transparent 15, 15'); assert.equal(canvas.isTargetTransparent(rect, 16, 16), true, 'transparent 16, 16'); - assert.equal(canvas.isTargetTransparent(rect, 17, 17), false, 'opaque 17, 17'); - assert.equal(canvas.isTargetTransparent(rect, 18, 18), false, 'opaque 18, 18'); - assert.equal(canvas.isTargetTransparent(rect, 19, 19), false, 'opaque 19, 19'); + assert.equal(canvas.isTargetTransparent(rect, 17, 17), true, 'transparent 17, 17'); + assert.equal(canvas.isTargetTransparent(rect, 18, 18), true, 'transparent 18, 18'); + assert.equal(canvas.isTargetTransparent(rect, 19, 19), true, 'transparent 19, 19'); assert.equal(canvas.isTargetTransparent(rect, 20, 20), false, 'opaque 20, 20'); assert.equal(canvas.isTargetTransparent(rect, 21, 21), false, 'opaque 21, 21'); assert.equal(canvas.isTargetTransparent(rect, 22, 22), false, 'opaque 22, 22'); assert.equal(canvas.isTargetTransparent(rect, 23, 23), false, 'opaque 23, 23'); - assert.equal(canvas.isTargetTransparent(rect, 24, 24), false, 'opaque 24, 24'); - assert.equal(canvas.isTargetTransparent(rect, 25, 25), false, 'opaque 25, 25'); - assert.equal(canvas.isTargetTransparent(rect, 26, 26), false, 'opaque 26, 26'); - assert.equal(canvas.isTargetTransparent(rect, 27, 27), false, 'opaque 27, 27'); - assert.equal(canvas.isTargetTransparent(rect, 28, 28), false, 'opaque 28, 28'); - assert.equal(canvas.isTargetTransparent(rect, 29, 29), false, 'opaque 29, 29'); - assert.equal(canvas.isTargetTransparent(rect, 30, 30), false, 'opaque 30, 30'); + assert.equal(canvas.isTargetTransparent(rect, 24, 24), true, 'transparent 24, 24'); + assert.equal(canvas.isTargetTransparent(rect, 25, 25), true, 'transparent 25, 25'); + assert.equal(canvas.isTargetTransparent(rect, 26, 26), true, 'transparent 26, 26'); + assert.equal(canvas.isTargetTransparent(rect, 27, 27), true, 'transparent 27, 27'); + assert.equal(canvas.isTargetTransparent(rect, 28, 28), true, 'transparent 28, 28'); + assert.equal(canvas.isTargetTransparent(rect, 29, 29), true, 'transparent 29, 29'); + assert.equal(canvas.isTargetTransparent(rect, 30, 30), true, 'transparent 30, 30'); assert.equal(canvas.isTargetTransparent(rect, 31, 31), true, 'transparent 31, 31'); }); From f7e58b3c2ce8ad881193a006d2cf5dc53dc76da2 Mon Sep 17 00:00:00 2001 From: Andrea Bogazzi Date: Sat, 30 Jan 2021 16:46:59 +0100 Subject: [PATCH 08/13] wrong command --- .github/workflows/build.js.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.js.yml b/.github/workflows/build.js.yml index 1cae7781c63..4bfc0378e62 100644 --- a/.github/workflows/build.js.yml +++ b/.github/workflows/build.js.yml @@ -38,7 +38,7 @@ jobs: with: node-version: 12.x - run: npm ci - - run: npm build:fast + - run: npm run build:fast - run: npm run coverage - uses: romeovs/lcov-reporter-action@v0.2.16 with: From d33f362607ead02708a4e9151382a48f0c9f66cb Mon Sep 17 00:00:00 2001 From: Andrea Bogazzi Date: Sat, 30 Jan 2021 16:54:54 +0100 Subject: [PATCH 09/13] change rport type --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 0f859d73753..b2087b5ab6f 100644 --- a/package.json +++ b/package.json @@ -49,7 +49,7 @@ "test:single": "qunit test/node_test_setup.js test/lib", "test:coverage": "nyc --silent qunit test/node_test_setup.js test/lib test/unit", "test:visual:coverage": "nyc --silent --no-clean qunit test/node_test_setup.js test/lib test/visual", - "cover:report": "nyc report --reporter=lcov --reporter=text", + "cover:report": "nyc report --reporter=lcov --reporter=text-summary", "coverage": "npm run test:coverage && npm run test:visual:coverage && npm run cover:report", "test": "qunit test/node_test_setup.js test/lib test/unit", "test:visual": "qunit test/node_test_setup.js test/lib test/visual", From 39aaab881a9ba8d0b3e38695f81a2123483e6429 Mon Sep 17 00:00:00 2001 From: Andrea Bogazzi Date: Sat, 30 Jan 2021 17:05:18 +0100 Subject: [PATCH 10/13] test this --- .github/workflows/build.js.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.js.yml b/.github/workflows/build.js.yml index 4bfc0378e62..da41a65fb0a 100644 --- a/.github/workflows/build.js.yml +++ b/.github/workflows/build.js.yml @@ -39,8 +39,7 @@ jobs: node-version: 12.x - run: npm ci - run: npm run build:fast - - run: npm run coverage - - uses: romeovs/lcov-reporter-action@v0.2.16 + - uses: ziishaned/jest-reporter-action@v0.0.1 with: github-token: ${{ secrets.GITHUB_TOKEN }} - lcov-file: ./coverage/lcov.info + test-command: "npm run coveragee" From 2265c5847d90daf4810dc5bdfe2a9aaaa2e8eb5e Mon Sep 17 00:00:00 2001 From: Andrea Bogazzi Date: Sat, 30 Jan 2021 17:09:36 +0100 Subject: [PATCH 11/13] maybefixed --- .github/workflows/build.js.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.js.yml b/.github/workflows/build.js.yml index da41a65fb0a..31760c211a1 100644 --- a/.github/workflows/build.js.yml +++ b/.github/workflows/build.js.yml @@ -39,7 +39,7 @@ jobs: node-version: 12.x - run: npm ci - run: npm run build:fast - - uses: ziishaned/jest-reporter-action@v0.0.1 + - uses: ChristiaanScheermeijer/jest-reporter-action@v0.4.0 with: github-token: ${{ secrets.GITHUB_TOKEN }} test-command: "npm run coveragee" From 2385529d7d34688f35b76a1f1db347ddd18652f7 Mon Sep 17 00:00:00 2001 From: Andrea Bogazzi Date: Sat, 30 Jan 2021 17:10:43 +0100 Subject: [PATCH 12/13] maybefixed --- .github/workflows/build.js.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.js.yml b/.github/workflows/build.js.yml index 31760c211a1..32d670301e6 100644 --- a/.github/workflows/build.js.yml +++ b/.github/workflows/build.js.yml @@ -42,4 +42,4 @@ jobs: - uses: ChristiaanScheermeijer/jest-reporter-action@v0.4.0 with: github-token: ${{ secrets.GITHUB_TOKEN }} - test-command: "npm run coveragee" + test-command: "npm run coverage" From 47f7329615db58aecc226af7f931a5d2e7f4014a Mon Sep 17 00:00:00 2001 From: Andrea Bogazzi Date: Sat, 30 Jan 2021 17:51:10 +0100 Subject: [PATCH 13/13] different output --- .github/workflows/build.js.yml | 3 ++- package.json | 3 +-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.js.yml b/.github/workflows/build.js.yml index 32d670301e6..26309aa9b70 100644 --- a/.github/workflows/build.js.yml +++ b/.github/workflows/build.js.yml @@ -39,7 +39,8 @@ jobs: node-version: 12.x - run: npm ci - run: npm run build:fast + - run: npm run test:coverage && npm run test:visual:coverage - uses: ChristiaanScheermeijer/jest-reporter-action@v0.4.0 with: github-token: ${{ secrets.GITHUB_TOKEN }} - test-command: "npm run coverage" + test-command: "npm run coverage:report" diff --git a/package.json b/package.json index b2087b5ab6f..df0cad59946 100644 --- a/package.json +++ b/package.json @@ -49,8 +49,7 @@ "test:single": "qunit test/node_test_setup.js test/lib", "test:coverage": "nyc --silent qunit test/node_test_setup.js test/lib test/unit", "test:visual:coverage": "nyc --silent --no-clean qunit test/node_test_setup.js test/lib test/visual", - "cover:report": "nyc report --reporter=lcov --reporter=text-summary", - "coverage": "npm run test:coverage && npm run test:visual:coverage && npm run cover:report", + "coverage:report": "nyc report --reporter=lcov --reporter=text", "test": "qunit test/node_test_setup.js test/lib test/unit", "test:visual": "qunit test/node_test_setup.js test/lib test/visual", "test:visual:single": "qunit test/node_test_setup.js test/lib",