Scale of container is not taken into account on a Groupable
Environments
- Framework name: React
- Framework version: 16.13.1
- Moveable Component version: 0.22.5 (react-moveable)
Description
When moving a single item in a scaled container (CSS transform: scale(0.5)), the throttleDrag and all the events (onDrag, etc) are adjusted to the scale of the container they're in. Moving a Groupable inside a scaled container, the throttleDrag and events such as onDragGroup delta aren't adjusted to the container its scale.
The difference can be seen in the sample below, when dragging the single item it correctly adjust its position to the mouse. When dragging the group, the group moves slower than the mouse.
https://codesandbox.io/s/happy-margulis-u5x3n?fontsize=14&hidenavigation=1&theme=dark
**Edit: ** updated to latest version of moveables and added rootContainer={document.body}
@jeroenm2
The movement of a single target is correct to move like a group.
So, the prop that added is rootContainer.
Set rootContainer={document.body}
<Moveable
rootContainer={document.body} />
@daybrush
Hi, thanks for you response
This seems to resolve the issue but unfortunately not on the latest version, I've updated the sample to the latest version of react-moveables
This code what i got same problem mentioned by @jeroenm2 Help me to find what i did wrong.
I set the transform programatically what i did wrong need to update anything in moveable?
const moveableElement = document.querySelector(".scena-viewport");
const moveable = new Moveable(moveableElement.parentElement, {
container: moveableElement,
target: [],
rootContainer: document.body,
draggable: true,
scalable: true,
rotatable: true,
snappable: true,
snapCenter: true,
dragArea: true,
roundable: true,
roundRelative: true,
origin: true,
keepRatio: true,
// throttleDrag: 0,
// throttleResize: 0,
// throttleScale: 0,
// throttleRotate: 0,
padding: {
left: 10,
top: 10,
right: 10,
bottom: 10
},
verticalGuidelines: [100, 200, 300],
horizontalGuidelines: [0, 100, 200],
});
const helper = MoveableHelper.create();
moveable
.on("dragStart", helper.onDragStart)
.on("drag", helper.onDrag)
.on("dragEnd", helper.onDragEnd)
.on("dragGroupStart", helper.onDragGroupStart)
.on("round", helper.onRound)
.on("dragGroup", helper.onDragGroup)
.on("scaleStart", helper.onScaleStart)
.on("scale", helper.onScale)
.on("scroll", helper.onScroll)
.on("scale", helper.onScale)
.on("scaleGroupStart", helper.onScaleGroupStart)
.on("scaleGroup", helper.onScaleGroup)
.on("rotateStart", helper.onRotateStart)
.on("rotate", helper.onRotate)
.on("rotateGroupStart", helper.onRotateGroupStart)
.on("rotateGroup", helper.onRotateGroup)
.on("transformStartEvent", helper.OnTransformStartEvent);
const selecto = new Selecto({
container: document.querySelector("body"),
dragContainer: ".scena-viewer",
hitRate: 1,
selectableTargets: ["[data-moveable]"],
toggleContinueSelect: ["shift"],
preventDefault:false,
scrollOptions: {
container: viewer.getContainer(),
threshold: 30,
throttleTime: 30,
getScrollPosition: ({
direction
}) => {
return [viewer.getScrollLeft(), viewer.getScrollTop()];
}
}
})

@sooryaraj
add dragGroupStart event
.on("dragGroupStart", helper.onDragGroupStart)
.on("dragGroup", helper.onDragGroup)
i had both functions but it's not working
@sooryaraj
Is there any address that I can test?
I had change style in transform that's why this problem. when i change transform to other style it's working
@sooryaraj
MoveableHelper's start transform is
{
translate: "0px, 0px",
scale: "1, 1",
rotate: "0deg",
}
If you want to use transform, you have to change the helper's start transform.
my layouts are load from json. when it's loaded and trying to move place it's reset to default transform.
if it's possible to set transform for every div and or get style of div and increase/decrease the pixels is little help in some ways