Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed bug positioning group #5176

Merged
merged 1 commit into from
Aug 18, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need to force this origin

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);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need to force this origin

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