-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
Weird group behavior - initialization vs add #1582
Comments
it's obvious that one updates the bounds of the group, and one doesn't, but the size of the group itself is static throughout, and that's what I thought it was using to position itself. |
I think you should simply use addWithUpdate method of group instead of add. The problem of addWithUpdate is that it reset your top - left position. |
@asturur that's a good idea, I like it |
after deeper checks, what i said has not much sense. When we multiselect object with mouse, we create a group, and we do not expect theyr position to change. When we create a group with initialize + objects, like test = 1 in the provided fiddle, we create the group and later top and left get applied. at the end best solution is add items when you create object, if you add later move the group with explicit request. in that case it works with test = 1 and 0. It is still a possible feature of course, but requires too much internal changes, i would support it if we decide to rework groups to support different relative coords ( from center, from topleft .... ) |
I also had problems with groups. I would expect that object will not move after being added to group. Of course I can use |
objects do not move. When you select with mouse, you implicitly think that the objects are defining the group. When you add the object by code, and you specify top and left of the group and width and height, you are asking something weird. Or you delete the objects position and you put everything in the group in the center, or topleft.... Otherwise what? Create a group, in a single line of code you specify width of 300, top 50, in the same line of code, you insert 2 objects, one has left 100 and one has left 1000, and both top of 300 what should happen? I hope what i'm pointing out is clear. |
What I mean is group that is dependent on objects that create it. Group width and height should be calculated by counting bounding rect around all its objects. The same with left and top. If you add new object to group or move it, left and top of group should be calculated according to that change. I'm going to create class |
I don't know, too much time since i read all that code of group.class, that i can say something that makes sense. |
Yes you right I will investigate it deeply. I will be working with it soon so I will let know here what approach I will take. Maybe it can be made by improving fabric.Group. But I can't say right now. I have to investigate Group code. |
Yes I also found working with instantiating groups to be a little Robert Franks 8 Bath Road +44 (0)7745 653196 skype: robertfranks Success is getting what you want On 14 January 2015 at 11:28, jagi [email protected] wrote:
|
I was investigating how groups work and one things seems to be counter intuitive - it's origin point. Right now you can set it only to one of three values The best situation would be to have I know that it would take entire Fabric to rewrite but I'm just dreaming :) |
i think i will close this old issue just specifing in docs that: add is suggested just for canvas @ncou do you feel like adding a comment over the jsdocs explaining a bit this situation? the method is add: in the collections mixin. |
Hi, I am away from my personal comuter for 2 weeks. I could try to add a comment as soon as im back, but my english is not perfect :), and you speak about the "add" method from the Group object. is that right ? |
I have been trying to figure out groups all day, and it seems that elements within a group position themselves different if added (group.add), versus initialized in the constructor.
I came up with an example here:
http://jsfiddle.net/anwjhs2o/1/
When we run the fiddle, we get expected results as this is a very popular demo (in the intro to fabric article). However, in the javascript, change the the "test" variable to be set to 1 so that it initializes the group differently, and see that the circles are now in different positions.
Is this expected behavior?
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.
The text was updated successfully, but these errors were encountered: