Skip to content

Commit

Permalink
fixed bug positioning group (fabricjs#5176)
Browse files Browse the repository at this point in the history
  • Loading branch information
asturur authored Aug 18, 2018
1 parent d78a6a6 commit 1413bae
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/brushes/circle_brush.class.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ fabric.CircleBrush = fabric.util.createClass(fabric.BaseBrush, /** @lends fabric

circles.push(circle);
}
var group = new fabric.Group(circles, { originX: 'center', originY: 'center' });
var group = new fabric.Group(circles);
group.canvas = this.canvas;

this.canvas.add(group);
Expand Down
2 changes: 1 addition & 1 deletion src/brushes/spray_brush.class.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ fabric.SprayBrush = fabric.util.createClass( fabric.BaseBrush, /** @lends fabric
rects = this._getOptimizedRects(rects);
}

var group = new fabric.Group(rects, { originX: 'center', originY: 'center' });
var group = new fabric.Group(rects);
this.shadow && group.setShadow(this.shadow);
this.canvas.add(group);
this.canvas.fire('path:created', { path: group });
Expand Down
12 changes: 12 additions & 0 deletions src/shapes/group.class.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,16 @@

if (!isAlreadyGrouped) {
var center = options && options.centerPoint;
// we want to set origins before calculating the bounding box.
// so that the topleft can be set with that in mind.
// if specific top and left are passed, are overwritten later
// with the callSuper('initialize', options)
if (options.originX !== undefined) {
this.originX = options.originX;
}
if (options.originY !== undefined) {
this.originY = options.originY;
}
// if coming from svg i do not want to calc bounds.
// i assume width and height are passed along options
center || this._calcBounds();
Expand Down Expand Up @@ -495,6 +505,8 @@
this.width = width;
this.height = height;
if (!onlyWidthHeight) {
// the bounding box always finds the topleft most corner.
// whatever is the group origin, we set up here the left/top position.
this.setPositionByOrigin({ x: left, y: top }, 'left', 'top');
}
},
Expand Down

0 comments on commit 1413bae

Please sign in to comment.