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 rotating, beforeRotate is called before rotate occurs. In beforeRotate, you can get and set the pre-value before rotating.
OptionalonWhen rotating the group, beforeRotateGroup is called before rotateGroup occurs. In beforeRotateGroup, you can get and set the pre-value before rotating.
OptionalonWhen scaling, beforeScale is called before scale occurs. In beforeScale, you can get and set the pre-value before scaling.
import Moveable from "@moveable-next/vanilla";
const moveable = new Moveable(document.body, { scalable: true });
moveable.on("beforeScale", ({ setFixedDirection }) => {
if (shiftKey) {
setFixedDirection([0, 0]);
}
});
moveable.on("scale", ({ target, transform, dist }) => {
target.style.transform = transform;
});
OptionalonWhen scaling the group, beforeScaleGroup is called before scaleGroup occurs. In beforeScaleGroup, you can get and set the pre-value before scaling.
OptionalonWhen pinching, the pinch event is called with part of scale, rotate, resize
import Moveable from "@moveable-next/vanilla";
const moveable = new Moveable(document.body, {
rotatable: true,
scalable: true,
pinchable: true, // ["rotatable", "scalable"]
});
moveable.on("pinch", ({ target }) => {
console.log(target);
});
moveable.on("rotate", ({ target }) => {
console.log(target);
});
moveable.on("scale", ({ target }) => {
console.log(target);
});
OptionalonWhen the pinch finishes, the pinchEnd event is called.
import Moveable from "@moveable-next/vanilla";
const moveable = new Moveable(document.body, {
rotatable: true,
scalable: true,
pinchable: true, // ["rotatable", "scalable"]
});
moveable.on("pinchEnd", ({ target }) => {
console.log(target);
});
moveable.on("rotateEnd", ({ target }) => {
console.log(target);
});
moveable.on("scaleEnd", ({ target }) => {
console.log(target);
});
OptionalonWhen the group pinch, the pinchGroup event is called.
OptionalonWhen the group pinch finishes, the pinchGroupEnd event is called.
OptionalonWhen the group pinch starts, the pinchGroupStart event is called.
OptionalonWhen the pinch starts, the pinchStart event is called with part of scaleStart, rotateStart, resizeStart
import Moveable from "@moveable-next/vanilla";
const moveable = new Moveable(document.body, {
rotatable: true,
scalable: true,
pinchable: true, // ["rotatable", "scalable"]
});
moveable.on("pinchStart", ({ target }) => {
console.log(target);
});
moveable.on("rotateStart", ({ target }) => {
console.log(target);
});
moveable.on("scaleStart", ({ target }) => {
console.log(target);
});
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.
OptionalonWhen rotating, the rotate event is called.
OptionalonWhen the rotate finishes, the rotateEnd event is called.
OptionalonWhen the group rotate, the rotateGroup event is called.
import Moveable from "@moveable-next/vanilla";
const moveable = new Moveable(document.body, {
target: [].slice.call(document.querySelectorAll(".target")),
rotatable: true
});
moveable.on("rotateGroup", ({ targets, events }) => {
console.log("onRotateGroup", targets);
events.forEach(ev => {
const target = ev.target;
// ev.drag is a drag event that occurs when the group rotate.
const left = ev.drag.beforeDist[0];
const top = ev.drag.beforeDist[1];
const deg = ev.beforeDist;
});
});
OptionalonWhen the group rotate finishes, the rotateGroupEnd event is called.
OptionalonWhen the group rotate starts, the rotateGroupStart event is called.
OptionalonWhen the rotate starts, the rotateStart event is called.
OptionalonWhen scaling, the scale event is called.
OptionalonWhen the scale finishes, the scaleEnd event is called.
OptionalonWhen the group scale, the scaleGroup event is called.
import Moveable from "@moveable-next/vanilla";
const moveable = new Moveable(document.body, {
target: [].slice.call(document.querySelectorAll(".target")),
scalable: true
});
moveable.on("scaleGroup", ({ targets, events }) => {
console.log("onScaleGroup", targets);
events.forEach(ev => {
const target = ev.target;
// ev.drag is a drag event that occurs when the group scale.
const left = ev.drag.beforeDist[0];
const top = ev.drag.beforeDist[1];
const scaleX = ev.scale[0];
const scaleY = ev.scale[1];
});
});
OptionalonWhen the group scale finishes, the scaleGroupEnd event is called.
OptionalonWhen the group scale starts, the scaleGroupStart event is called.
OptionalonWhen the scale starts, the scaleStart event is called.
OptionalpinchableWhether or not target can be pinched with draggable, resizable, scalable, rotatable.
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.
OptionalresolveSets the control that will cause resize along with rotate. (Only Single Target, Only resizable, Beta)
OptionalrotatableWhether or not target can be rotated.
OptionalrotateYou can rotate around direction controls.
Either rotateAroundControls or displayAroundControls can be used.
OptionalrotationYou can specify the position of the rotation.
OptionalrotationSet additional rotationTargets.
OptionalscalableWhether or not target can be scaled.
Optionalthrottlethrottle of width, height when resize. If throttleResize is set to less than 1, the target may shake.
Optionalthrottlethrottle of angle(degree) when rotate.
Optionalthrottlethrottle of scaleX, scaleY when scale.
Whether to recalculate when the size to be calculated is different from the actual size