Skip to content

Commit

Permalink
fix(fabric.Object) Fix control flip and control box (#7412)
Browse files Browse the repository at this point in the history
  • Loading branch information
asturur authored Oct 3, 2021
1 parent df7e86a commit d277016
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/shapes/object.class.js
Original file line number Diff line number Diff line change
Expand Up @@ -1401,6 +1401,9 @@
if (!this.group) {
ctx.globalAlpha = this.isMoving ? this.borderOpacityWhenMoving : 1;
}
if (this.flipX) {
options.angle -= 180;
}
ctx.rotate(degreesToRadians(options.angle));
if (styleOverride.forActiveSelection || this.group) {
drawBorders && this.drawBordersInGroup(ctx, options, styleOverride);
Expand Down
2 changes: 2 additions & 0 deletions src/shapes/text.class.js
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,8 @@
/**
* Return a context for measurement of text string.
* if created it gets stored for reuse
* this is for internal use, please do not use it
* @private
* @param {String} text Text string
* @param {Object} [options] Options object
* @return {fabric.Text} thisArg
Expand Down
23 changes: 23 additions & 0 deletions test/visual/control_rendering.js
Original file line number Diff line number Diff line change
Expand Up @@ -261,5 +261,28 @@
fabricClass: 'Canvas',
});

function controlboxFlippedX(canvas, callback) {
var rect = new fabric.Rect({
width: 90, height: 90, padding: 4, angle: 15, flipX: true,
cornerSize: 12, cornerColor: 'green', cornerStrokeColor: 'pink',
transparentCorners: true, borderScaleFactor: 3,
fill: 'red', top: 35, left: 35,
});
canvas.add(rect);
canvas.setActiveObject(rect);
canvas.renderAll();
callback(canvas.lowerCanvasEl);
}

tests.push({
test: 'controlbox with flipped X',
code: controlboxFlippedX,
golden: 'controls11.png',
percentage: 0.004,
width: 150,
height: 170,
fabricClass: 'Canvas',
});

tests.forEach(visualTestLoop(QUnit));
})();
Binary file added test/visual/golden/controls11.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit d277016

Please sign in to comment.