Moveable
    Preparing search index...

    Interface ScalableProps

    interface ScalableProps {
        displayAroundControls?: boolean;
        edge?: boolean | LineDirection[];
        keepRatio?: boolean;
        onBeforeScale?: (e: OnBeforeScale) => any;
        onBeforeScaleGroup?: (e: OnBeforeScaleGroup) => 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;
        renderDirections?: boolean | string[];
        scalable?: boolean | ScalableOptions;
        throttleScale?: number;
    }

    Hierarchy (View Summary)

    Index
    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
    
    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.

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