OptionalcheckOptionaldisplayYou can expand the area around the control.
Either rotateAroundControls or displayAroundControls can be used.
You can set the area through the controlPadding value.
OptionaledgeWhether to scale and resize through edge lines. You can use "n", "w", "s", "e" in LineDirection array.
OptionalkeepWhen resize or scale, keeps a ratio of the width, height.
OptionalkeepThe size can be changed by format and throttle, but the ratio is maintained at the end. Forced true when using groups.
OptionalonWhen resizing, beforeResize is called before resize occurs. In beforeResize, you can get and set the pre-value before resizing.
import Moveable from "@moveable-next/vanilla";
const moveable = new Moveable(document.body, { resizable: true });
moveable.on("beforeResize", ({ setFixedDirection }) => {
if (shiftKey) {
setFixedDirection([0, 0]);
}
});
moveable.on("resize", ({ target, width, height, drag }) => {
target.style.width = `${width}px`;
target.style.height = `${height}px`;
target.style.transform = drag.transform;
});
OptionalonWhen resizing the group, beforeResizeGroup is called before resizeGroup occurs. In beforeResizeGroup, you can get and set the pre-value before resizing.
OptionalonWhen resizing, the resize event is called.
OptionalonWhen the resize finishes, the resizeEnd event is called.
OptionalonWhen the group resize, the resizeGroup event is called.
import Moveable from "@moveable-next/vanilla";
const moveable = new Moveable(document.body, {
target: [].slice.call(document.querySelectorAll(".target")),
resizable: true
});
moveable.on("resizeGroup", ({ targets, events }) => {
console.log("onResizeGroup", targets);
events.forEach(ev => {
const offset = [
direction[0] < 0 ? -ev.delta[0] : 0,
direction[1] < 0 ? -ev.delta[1] : 0,
];
// ev.drag is a drag event that occurs when the group resize.
const left = offset[0] + ev.drag.beforeDist[0];
const top = offset[1] + ev.drag.beforeDist[1];
const width = ev.width;
const top = ev.top;
});
});
OptionalonWhen the group resize finishes, the resizeGroupEnd event is called.
OptionalonWhen the group resize starts, the resizeGroupStart event is called.
OptionalonWhen the resize starts, the resizeStart event is called.
OptionalrenderSet directions to show the control box.
import Moveable from "@moveable-next/vanilla";
const moveable = new Moveable(document.body, {
warpable: true,
renderDirections: ["n", "nw", "ne", "s", "se", "sw", "e", "w"],
});
moveable.renderDirections = ["nw", "ne", "sw", "se"];
OptionalresizableWhether or not target can be resized.
OptionalresizeFunction to convert size for resize.
Optionalthrottlethrottle of width, height when resize. If throttleResize is set to less than 1, the target may shake.
Whether to recalculate when the size to be calculated is different from the actual size