-
-
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
V6
: 🎉 Group Rewrite
#7670
Comments
First milestone #7858 🤟 |
First milestone is merged!! 🥳🥳 |
updated description |
updated |
Second milestone merged! new fabric.Group(objects, {
subTargetCheck: true,
interactive: true // enables selecting subtargets
}) |
4th milestone merged! |
@asturur I think we can drop coords in favor of |
Group layout now respects origin, skewing and angle. |
Group is now in beta! |
Next Up
|
Thanks @ShaMan123 , it is working for me with Sorry to pour here with questions, I realise you guys must be super-busy, but I also feel bringing up problems right now is best for all of us.
Is it possible to select the Are there a couple of event listeners that might help selecting the |
Rect.selectable = false? |
It will make the rect unselectable/non-interactive which is also something I don't want. I just tried this use-case in Canva, and in Canva if I create a rectangle of 50x50 and place a circle of 30x30 inside it, then group both of them. Then when I select the group to move, the whole group moves and I am not able to move the rectangle or circle although I can change their attributes. I wonder what event listeners we can use, for example if a user moves a group without Shift key pressed, we deal with the group but if Shift key is pressed, we can select the individual object inside the group. If this is an advanced topic for us, we can have a look at it later, but important to at least think about it because we are sure this is not an unusual case. |
Did you try toggling the selectable prop in correlation to the shift key? |
Sorry but can you please point me to that in the code from where I see how
it works? Thanks.
…On Sat, 20 May 2023, 02:40 Shachar, ***@***.***> wrote:
Did you try toggling the selectable prop in correlation to the shift key?
You can also try to fiddle with onSelect, onDeselect and the related events
—
Reply to this email directly, view it on GitHub
<#7670 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABW3JIVLM2CUAQTTGVW7QJ3XG7SGXANCNFSM5OAWEAHQ>
.
You are receiving this because you commented.Message ID: <fabricjs/fabric.
***@***.***>
|
@ShaMan123 I tried setting the Is there any way we can set |
@asturur can you help with my comment above? If I can make some objects in a group interactive and some not, that would be golden for the project I'm working on. If this is not in the plan for now, that would work as well if I can get to know. Thanks for this great package! cc: @ShaMan123 |
Open a dedicated discussion/issue |
@abdussami-tayyab link the open issue when you open it. |
@asturur do we have a boilerplate JSFiddle or CodeSandbox that I can use to replicate my issue? Thanks! |
Any update on the implementation of this DEMO in V6? |
Are you referring to toGroup/toActiveSelection?
canvas.getActiveSelection().add(...group.removeAll())
//or
canvas.setActiveObject(new ActiveSelection(group.removeAll())
// remove group
new Group(canvas.getActiveObjects()) |
Thanks, your code is very clean, I used a lot of code to achieve a similar result. |
Yes, v6 is a major step forward for the repo and the group rewrite especially |
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
Guys I am hiding your last off topic comments |
Group rewrite has completed a while back and the LayoutManager has been introduced. #8034 hasn't been merged so look out when adding objects to a group that belonged to a canvas. Call The parent ref has been introduced to complement the existing group ref. There are pending issues with the transform system and the caching system that will cause bugs when using groups such as: I suggest anyone needing nested objects and groups to familiarize with |
V6
Hi everyone,
fabric is moving forward!
We have 2 main goals for v6:
You can see #8316
Group Rewrite
This is a tracking issue for the group rewrite, read below for more detail including the current state of things and gist.
We aim to fix and support long desired features including:
Motivating Issues/Discussions
#7473 #7316 #6776 #7136 #7299 #7130 #7142 #7449 and anything with a
group
tagHow do you fit in?
IMPORTANT NOTICE: all changes made to the v6 branch are experimental and can be removed or changed without notice and without proper support (including supported features from v5). fabric might change drastically between commits. Meaning if you want in - it's on you.
You can join the effort by contributing
This description is updated continuously with relevant information
You don't need to scroll and read endless comments (unless you are a maintainer :))
Current State
Fixed logic across fabric for nested objects to be selectable.
Group has been completely rewritten and Layer has been introduced. As part of the rewrite group is now a layout engine, you can use it to customize layout of objects.
In general the rewrite allows any object to be selectable and interactive if it is referenced in the
_objects
array of it's parent and it references it's parent via thegroup
property. If you build custom objects with nesting this is what you are looking for.Usage
It is advised to use
set
on group/objects from now on (until #7596 is done, then it might change due to setters)Changing
subTargetCheck
orinteractive
enables/disables crucial functionality so for these props it is not an advice but a MUST.Progress
fix(ActiveSelection): 🔃preserveObjectStacking
📌 #7878fix(ActiveSelection): 🚀 multiple nested selection 🗂️ #7882fill-parent
layout #7901 needs porting to v6Object#parent
=> rmisActiveSelection
#8951Experimental
Triggering Layout
#9148 extracts layout management to a standalone class
triggerLayout
forces a group to recalculate its bounding box and reposition its objects.You can define a layout strategy and assign it to the layout manager.
Read the code, it has comments explaining stuff and types that make it clear what you need to return from the method.
Look at the modified trigger, it is possible adding more triggers.
However I will promote an overall solution.
#7882 is a POC, follow the progress trigger
BREAKING
addWithUpdate
are removed includingtoGroup
/toActiveSelection
moveTo
->moveObjectTo
)remove
before adding to another group, fabric handles it internallyPitfalls
All object origin methods (e.g.
translateToOriginPoint
) are relative methods.You should use them ONLY in the correct plane and with points that belong to the relative plane.
IMO it makes them worthless.
#8767 changes that.
BUGS
If you encounter bugs related to group or if you have a feature request please submit a relevant ticket.
Notice that bug reports of versions below v6 will be completely disregarded and closed. This was hard work, put effort into your repro so it is in v6.
Working Examples
Usingv6!
stale branch- CodeSandbox or JSFiddle- Layer or in JSFiddleTo Do
dblClick
to select nested objects? create mechanism for dev to customize selection? for now overridesearchPossibleTargets
fabric.js/src/canvas.class.js
Line 422 in 109efe5
_chooseObjectsToRender
)preserveObjectStacking
in favor of a drag image/ghost - can wait/stale due to fix(ActiveSelection): 🔃preserveObjectStacking
📌 #7878getLocalPointer
8bf7f92)phase out coords (can be delayed, now that bbox and controls are fixed)Redo coords #8767shouldCache
method_renderObjects
- nested active object will fail withperPixelTargetFind
because it will not get rendered by group (add logic tocanvas.isTargetTransparent
) feat(Group): render selected objects #7863ActiveSelection
caching - why not?removeAll
insteadgetObjectsBoundingBox
- needs work to exactly fit when group is rotatedoriginX/Y
407023c andangle
fix(Group): 6th Patch of New Group 🛠️ layout, angle and origin ⚡ #7867centerObject
methods:object.setRelativeCenterPoint(new Point())
object.setRelativeCenterPoint(new Point(object.getRelativeCenterPoint().x, 0))
clipPath
become evented/interactive? feat(V6): interactive clip path #7879groupSVGElements
support fill, strokewill not be supported by fabric, see feat(Group): 2nd Patch of New Group! 🎉 #7859 (comment)backgroundColor
- might be replaced withfill-parent
layout for objectcanvas.getActiveObjects().includes(obj)
removed
event dereferencing inconsistency feat(Group): 2nd Patch of New Group! 🎉 #7859 (comment)_ - fixed by fix(Group): patch #7916 #8000Redo coords #8767flipX/Y
on group and/or nested objects is a complete messLook
Video is running in original speed
Cutting Edge
The blue circles are rendered by a textbox and because of the rewrite with a few lines of code I got this working
Pay no attention to caching of course
This is EXTREMELY exciting because it means that anyone could create custom objects subclassing whatever object they need and have nested selection work out of the box!
The text was updated successfully, but these errors were encountered: