Open byeval opened 1 week ago
The bug happens only if you do it inside object:modified. not if you just exec the code one step after another. Need to look into it
@asturur Thank you for your reply! You are right, but I want switch object's artboard when user is dragging object in modify callback, Do you know how to solve this problem.
@asturur Thank you for your reply! You are right, but I want switch object's artboard when user is dragging object in modify callback, Do you know how to solve this problem.
@byeval Can you check if this method meets your requirements? When you drag multiple items to the target group(XXX), you need to first remove them from ac. When you drag a single item, you need to reset the cache.
canvas.on("mouse:move", e => {
const target = e.target;
if (!canvas.selection) return;
if (e.transform?.action != "drag") return;
if (!target) return;
const isA = target instanceof ActiveSelection;
const fn = (o: FabricObject) => {
(o.group ?? canvas).remove(o);
// XXX -> The "XXX" in your example === group
XXX.add(o);
}
if (isA) {
const list = target.getObjects();
for (const item of list) {
target.remove(item);
fn(item);
target.add(item);
}
} else {
canvas._activeObject = undefined;
canvas._hoveredTarget = undefined;
fn(target);
canvas._activeObject = target;
canvas._hoveredTarget = target;
canvas._setupCurrentTransform(e.e, target, true);
}
});
@zhe-he It works! Thank you so much ❤️
CheckList
Version
6.0.2
In What environments are you experiencing the problem?
Chrome
Node Version (if applicable)
None
Link To Reproduction
https://codesandbox.io/p/sandbox/group-clippath-fabric-js-6-0-0-beta-14-forked-8zzx2r?file=%2Fsrc%2Findex.js%3A36%2C21
Steps To Reproduce
Expected Behavior
control is fit with object
Actual Behavior
control has wrong position
Error Message & Stack Trace
No response