Moveable
    Preparing search index...

    Interface PinchableProps

    interface PinchableProps {
        checkResizableError?: boolean;
        displayAroundControls?: boolean;
        edge?: boolean | LineDirection[];
        keepRatio?: boolean;
        keepRatioFinally?: boolean;
        onBeforeResize?: (e: OnBeforeResize) => any;
        onBeforeResizeGroup?: (e: OnBeforeResizeGroup) => any;
        onBeforeRotate?: (e: OnBeforeRotate) => any;
        onBeforeRotateGroup?: (e: OnBeforeRotateGroup) => any;
        onBeforeScale?: (e: OnBeforeScale) => any;
        onBeforeScaleGroup?: (e: OnBeforeScaleGroup) => any;
        onPinch?: (e: OnPinch) => any;
        onPinchEnd?: (e: OnPinchEnd) => any;
        onPinchGroup?: (e: OnPinchGroup) => any;
        onPinchGroupEnd?: (e: OnPinchGroupEnd) => any;
        onPinchGroupStart?: (e: OnPinchGroupStart) => any;
        onPinchStart?: (e: OnPinchStart) => any;
        onResize?: (e: OnResize) => any;
        onResizeEnd?: (e: OnResizeEnd) => any;
        onResizeGroup?: (e: OnResizeGroup) => any;
        onResizeGroupEnd?: (e: OnResizeGroupEnd) => any;
        onResizeGroupStart?: (e: OnResizeGroupStart) => any;
        onResizeStart?: (e: OnResizeStart) => any;
        onRotate?: (e: OnRotate) => any;
        onRotateEnd?: (e: OnRotateEnd) => any;
        onRotateGroup?: (e: OnRotateGroup) => any;
        onRotateGroupEnd?: (e: OnRotateGroupEnd) => any;
        onRotateGroupStart?: (e: OnRotateGroupStart) => any;
        onRotateStart?: (e: OnRotateStart) => any;
        onScale?: (e: OnScale) => any;
        onScaleEnd?: (e: OnScaleEnd) => any;
        onScaleGroup?: (e: OnScaleGroup) => any;
        onScaleGroupEnd?: (e: OnScaleGroupEnd) => any;
        onScaleGroupStart?: (e: OnScaleGroupStart) => any;
        onScaleStart?: (e: OnScaleStart) => any;
        pinchable?: boolean | ("rotatable" | "resizable" | "scalable")[];
        renderDirections?: boolean | string[];
        resizable?: boolean | ResizableOptions;
        resizeFormat?: (size: number[]) => number[];
        resolveAblesWithRotatable?: Record<string, LineDirection[]> | null;
        rotatable?: boolean | RotatableOptions;
        rotateAroundControls?: boolean;
        rotationPosition?: RotationPosition | RotationPosition[];
        rotationTarget?:
            | false
            | MoveableRefType<SVGElement | HTMLElement>
            | ArrayFormat<MoveableRefType<SVGElement | HTMLElement>>;
        scalable?: boolean | ScalableOptions;
        throttleResize?: number;
        throttleRotate?: number;
        throttleScale?: number;
    }

    Hierarchy (View Summary)

    Index
    checkResizableError?: boolean

    Whether to recalculate when the size to be calculated is different from the actual size

    true
    
    displayAroundControls?: boolean

    You can expand the area around the control. Either rotateAroundControls or displayAroundControls can be used. You can set the area through the controlPadding value.

    0.44.0

    false
    
    edge?: boolean | LineDirection[]

    Whether to scale and resize through edge lines. You can use "n", "w", "s", "e" in LineDirection array.

    false
    
    keepRatio?: boolean

    When resize or scale, keeps a ratio of the width, height.

    false
    
    import Moveable from "@moveable-next/vanilla";

    const moveable = new Moveable(document.body, {
    scalable: true,
    });

    moveable.keepRatio = true;
    import Moveable from "@moveable-next/vanilla";

    const moveable = new Moveable(document.body, {
    resizable: true,
    });

    moveable.keepRatio = true;
    keepRatioFinally?: boolean

    The size can be changed by format and throttle, but the ratio is maintained at the end. Forced true when using groups.

    false
    
    onBeforeResize?: (e: OnBeforeResize) => any

    When 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;
    });
    onBeforeResizeGroup?: (e: OnBeforeResizeGroup) => any

    When resizing the group, beforeResizeGroup is called before resizeGroup occurs. In beforeResizeGroup, you can get and set the pre-value before resizing.

    onBeforeRotate?: (e: OnBeforeRotate) => any

    When rotating, beforeRotate is called before rotate occurs. In beforeRotate, you can get and set the pre-value before rotating.

    onBeforeRotateGroup?: (e: OnBeforeRotateGroup) => any

    When rotating the group, beforeRotateGroup is called before rotateGroup occurs. In beforeRotateGroup, you can get and set the pre-value before rotating.

    onBeforeScale?: (e: OnBeforeScale) => any

    When 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;
    });
    onBeforeScaleGroup?: (e: OnBeforeScaleGroup) => any

    When scaling the group, beforeScaleGroup is called before scaleGroup occurs. In beforeScaleGroup, you can get and set the pre-value before scaling.

    onPinch?: (e: OnPinch) => any

    When 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);
    });
    onPinchEnd?: (e: OnPinchEnd) => any

    When 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);
    });
    onPinchGroup?: (e: OnPinchGroup) => any

    When the group pinch, the pinchGroup event is called.

    import Moveable from "@moveable-next/vanilla";

    const moveable = new Moveable(document.body, {
    target: [].slice.call(document.querySelectorAll(".target")),
    pinchable: true
    });
    moveable.on("pinchGroup", ({ targets, events }) => {
    console.log("onPinchGroup", targets);
    });
    onPinchGroupEnd?: (e: OnPinchGroupEnd) => any

    When the group pinch finishes, the pinchGroupEnd event is called.

    import Moveable from "@moveable-next/vanilla";

    const moveable = new Moveable(document.body, {
    target: [].slice.call(document.querySelectorAll(".target")),
    pinchable: true
    });
    moveable.on("pinchGroupEnd", ({ targets, isDrag }) => {
    console.log("onPinchGroupEnd", targets, isDrag);
    });
    onPinchGroupStart?: (e: OnPinchGroupStart) => any

    When the group pinch starts, the pinchGroupStart event is called.

    import Moveable from "@moveable-next/vanilla";

    const moveable = new Moveable(document.body, {
    target: [].slice.call(document.querySelectorAll(".target")),
    pinchable: true
    });
    moveable.on("pinchGroupStart", ({ targets }) => {
    console.log("onPinchGroupStart", targets);
    });
    onPinchStart?: (e: OnPinchStart) => any

    When 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);
    });
    onResize?: (e: OnResize) => any

    When resizing, the resize event is called.

    import Moveable from "@moveable-next/vanilla";

    const moveable = new Moveable(document.body, { resizable: true });
    moveable.on("resize", ({ target, width, height }) => {
    target.style.width = `${e.width}px`;
    target.style.height = `${e.height}px`;
    });
    onResizeEnd?: (e: OnResizeEnd) => any

    When the resize finishes, the resizeEnd event is called.

    import Moveable from "@moveable-next/vanilla";

    const moveable = new Moveable(document.body, { resizable: true });
    moveable.on("resizeEnd", ({ target, isDrag }) => {
    console.log(target, isDrag);
    });
    onResizeGroup?: (e: OnResizeGroup) => any

    When 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;
    });
    });
    onResizeGroupEnd?: (e: OnResizeGroupEnd) => any

    When the group resize finishes, the resizeGroupEnd 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("resizeGroupEnd", ({ targets, isDrag }) => {
    console.log("onResizeGroupEnd", targets, isDrag);
    });
    onResizeGroupStart?: (e: OnResizeGroupStart) => any

    When the group resize starts, the resizeGroupStart 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("resizeGroupStart", ({ targets }) => {
    console.log("onResizeGroupStart", targets);
    });
    onResizeStart?: (e: OnResizeStart) => any

    When the resize starts, the resizeStart event is called.

    import Moveable from "@moveable-next/vanilla";

    const moveable = new Moveable(document.body, { resizable: true });
    moveable.on("resizeStart", ({ target }) => {
    console.log(target);
    });
    onRotate?: (e: OnRotate) => any

    When rotating, the rotate event is called.

    import Moveable from "@moveable-next/vanilla";

    const moveable = new Moveable(document.body, { rotatable: true });
    moveable.on("rotate", ({ target, transform, dist }) => {
    target.style.transform = transform;
    });
    onRotateEnd?: (e: OnRotateEnd) => any

    When the rotate finishes, the rotateEnd event is called.

    import Moveable from "@moveable-next/vanilla";

    const moveable = new Moveable(document.body, { rotatable: true });
    moveable.on("rotateEnd", ({ target, isDrag }) => {
    console.log(target, isDrag);
    });
    onRotateGroup?: (e: OnRotateGroup) => any

    When 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;
    });
    });
    onRotateGroupEnd?: (e: OnRotateGroupEnd) => any

    When the group rotate finishes, the rotateGroupEnd 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("rotateGroupEnd", ({ targets, isDrag }) => {
    console.log("onRotateGroupEnd", targets, isDrag);
    });
    onRotateGroupStart?: (e: OnRotateGroupStart) => any

    When the group rotate starts, the rotateGroupStart 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("rotateGroupStart", ({ targets }) => {
    console.log("onRotateGroupStart", targets);
    });
    onRotateStart?: (e: OnRotateStart) => any

    When the rotate starts, the rotateStart event is called.

    import Moveable from "@moveable-next/vanilla";

    const moveable = new Moveable(document.body, { rotatable: true });
    moveable.on("rotateStart", ({ target }) => {
    console.log(target);
    });
    onScale?: (e: OnScale) => any

    When scaling, the scale event is called.

    import Moveable from "@moveable-next/vanilla";

    const moveable = new Moveable(document.body, { scalable: true });
    moveable.on("scale", ({ target, transform, dist }) => {
    target.style.transform = transform;
    });
    onScaleEnd?: (e: OnScaleEnd) => any

    When the scale finishes, the scaleEnd event is called.

    import Moveable from "@moveable-next/vanilla";

    const moveable = new Moveable(document.body, { scalable: true });
    moveable.on("scaleEnd", ({ target, isDrag }) => {
    console.log(target, isDrag);
    });
    onScaleGroup?: (e: OnScaleGroup) => any

    When 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];
    });
    });
    onScaleGroupEnd?: (e: OnScaleGroupEnd) => any

    When the group scale finishes, the scaleGroupEnd 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("scaleGroupEnd", ({ targets, isDrag }) => {
    console.log("onScaleGroupEnd", targets, isDrag);
    });
    onScaleGroupStart?: (e: OnScaleGroupStart) => any

    When the group scale starts, the scaleGroupStart 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("scaleGroupStart", ({ targets }) => {
    console.log("onScaleGroupStart", targets);
    });
    onScaleStart?: (e: OnScaleStart) => any

    When the scale starts, the scaleStart event is called.

    import Moveable from "@moveable-next/vanilla";

    const moveable = new Moveable(document.body, { scalable: true });
    moveable.on("scaleStart", ({ target }) => {
    console.log(target);
    });
    pinchable?: boolean | ("rotatable" | "resizable" | "scalable")[]

    Whether or not target can be pinched with draggable, resizable, scalable, rotatable.

    false
    
    import Moveable from "@moveable-next/vanilla";

    const moveable = new Moveable(document.body);

    moveable.pinchable = true;
    renderDirections?: boolean | string[]

    Set directions to show the control box.

    false if rotatable, ["n", "nw", "ne", "s", "se", "sw", "e", "w"] otherwise
    
    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"];
    import Moveable from "@moveable-next/vanilla";

    const moveable = new Moveable(document.body, {
    scalable: true,
    renderDirections: ["n", "nw", "ne", "s", "se", "sw", "e", "w"],
    });

    moveable.renderDirections = ["nw", "ne", "sw", "se"];
    import Moveable from "@moveable-next/vanilla";

    const moveable = new Moveable(document.body, {
    resizable: true,
    renderDirections: ["n", "nw", "ne", "s", "se", "sw", "e", "w"],
    });

    moveable.renderDirections = ["nw", "ne", "sw", "se"];
    resizable?: boolean | ResizableOptions

    Whether or not target can be resized.

    false
    
    import Moveable from "@moveable-next/vanilla";

    const moveable = new Moveable(document.body, {
    resizable: false,
    });

    moveable.resizable = true;
    resizeFormat?: (size: number[]) => number[]

    Function to convert size for resize.

    oneself
    
    import Moveable from "@moveable-next/vanilla";

    const moveable = new Moveable(document.body, {
    resizable: true,
    resizeFormat: v => v,
    });

    moveable.resizeFormat = (size: number[]) => ([Math.trunc(size[0]), Math.trunc(size[1])];
    resolveAblesWithRotatable?: Record<string, LineDirection[]> | null

    Sets the control that will cause resize along with rotate. (Only Single Target, Only resizable, Beta)

    null
    
    rotatable?: boolean | RotatableOptions

    Whether or not target can be rotated.

    false
    
    import Moveable from "@moveable-next/vanilla";

    const moveable = new Moveable(document.body);

    moveable.rotatable = true;
    rotateAroundControls?: boolean

    You can rotate around direction controls. Either rotateAroundControls or displayAroundControls can be used.

    0
    
    rotationPosition?: RotationPosition | RotationPosition[]

    You can specify the position of the rotation.

    "top"
    
    import Moveable from "@moveable-next/vanilla";

    const moveable = new Moveable(document.body, {
    rotationPosition: "top",
    });

    moveable.rotationPosition = "bottom"
    rotationTarget?:
        | false
        | MoveableRefType<SVGElement | HTMLElement>
        | ArrayFormat<MoveableRefType<SVGElement | HTMLElement>>

    Set additional rotationTargets.

    null
    
    scalable?: boolean | ScalableOptions

    Whether or not target can be scaled.

    false
    
    import Moveable from "@moveable-next/vanilla";

    const moveable = new Moveable(document.body);

    moveable.scalable = true;
    throttleResize?: number

    throttle of width, height when resize. If throttleResize is set to less than 1, the target may shake.

    1
    
    import Moveable from "@moveable-next/vanilla";

    const moveable = new Moveable(document.body, {
    resizable: true,
    throttleResize: 1,
    });

    moveable.throttleResize = 0;
    throttleRotate?: number

    throttle of angle(degree) when rotate.

    0
    
    import Moveable from "@moveable-next/vanilla";

    const moveable = new Moveable(document.body);

    moveable.throttleRotate = 1;
    throttleScale?: number

    throttle of scaleX, scaleY when scale.

    0
    
    import Moveable from "@moveable-next/vanilla";

    const moveable = new Moveable(document.body);

    moveable.throttleScale = 0.1;