-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Preserve order of selected objects in multiple selection #4529
Comments
Well we have many problem about this, we can discuss them
you select first C then B. that means probably C is down and B up. Then if we would group them at some point, chosing |
For my application the z-order is irrelevant. I allow selecting objects only on the same logical "layer" and from the user perspective all such objects are on the same "plane". Of course the z-order is still present (when the objects overlap during move, etc) but I need to hide it from the user as much as possible. |
so and so. I'm unsure how many things change and how may apps change as a consequence |
What about the parallel data structure in |
I want to position selected objects according to the last selected object. But I am having trouble because the array list of choice is alphabetical. Can you help me with this? @asturur |
i really can t help each question. You should really make an use case on stackoverflow with everything possible to help people answer |
You're right. Thank you, though. :) |
you should post back the link question here |
Hello, |
@Clem-D can you make a fiddle that show what difficulties are you facing? |
Actually I can't, I'm using fabricJS v2.4.2 and fiddle only goes to 1.7 so I get a strange error if you want to have a look : http://jsfiddle.net/zsthLj6v/2/ Anyway my issue is not so complicated ; when user select shapes I want to have access the order he selected them. |
http://jsfiddle.net/fabricjs/Da7SP the suggested fiddle is always linked to the master dist folder. You can have a look here. I ll give a look at the cdn meanwhile |
I'm sorry I'm very not familiar with JSFiddle |
https://jsfiddle.net/z5av340j/1/ I have the following case: I must have 'canvas.preserveObjectStacking: true' and 'perPixelTargetFind: true'. I have Red square at bottom, Green Circle in middle and Blue triangle at top. Then i want to create a group that preserve this order. I cannot use mouse click and drag to create the selection because i may have other objects in the area. Using shift and click, starting in the most top till bottom, i get the group with the red square at front. To achieve the result i pretend, i have to click the objects from bottom to top, which in my opinion can be less friendly to the user. In my opinion toGroup() should always respect the relative order that the involved objects have in canvas.getObjects() |
i think toGroup is taking the objects as they are in the activeSelection and moving them in the group. As they are. There is not a solution that fits all. There are diffeent things at stake in this issue default rendering order with preserveObjectStacking true and default rendering order with preserveObjectStacking false and default rendering order of a group created from a selection. Now toGroup is a method called once in a while and not each render. We could provide a callback that takes in input the objects of the activeSelection, and the objects of the canvas and let you output an array of objects reordered. For the default rendering order we can make an option eventually if is an easy implementation. I do not feel like taking a stance toward a natural order, since i do not think there is one. |
Group rewrite makes this pretty straight forward to handle however you like. |
Feature request:
Currently when user selects multiple objects (holding down Shift key) the code in the library converts single selection to multiple selection when selecting the second object with the following code:
As implemented the order of two first items in the multiselection depends on the Z-order of these two first objects. As such, the library prevents application developer from knowing the order in which objects were selected. Such knowledge is important to implement group operations (like align for example) where first selected object is used as a "reference".
https://stackoverflow.com/questions/47614090/preserve-the-order-of-selected-objects
The text was updated successfully, but these errors were encountered: