Moveable
    Preparing search index...

    Interface ResizableProps

    interface ResizableProps {
        checkResizableError?: boolean;
        displayAroundControls?: boolean;
        edge?: boolean | LineDirection[];
        keepRatio?: boolean;
        keepRatioFinally?: boolean;
        onBeforeResize?: (e: OnBeforeResize) => any;
        onBeforeResizeGroup?: (e: OnBeforeResizeGroup) => 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;
        renderDirections?: boolean | string[];
        resizable?: boolean | ResizableOptions;
        resizeFormat?: (size: number[]) => number[];
        throttleResize?: 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.

    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);
    });
    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])];
    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;