Moveable
    Preparing search index...

    Interface SnappableProps

    interface SnappableProps {
        bounds?: BoundType | null;
        elementGuidelines?: (
            ElementGuidelineValueOption
            | MoveableRefType<Element>
        )[];
        elementSnapDirections?: boolean | SnapDirections;
        horizontalGuidelines?: (string | number | PosGuideline)[];
        innerBounds?: InnerBoundType | null;
        isDisplayGridGuidelines?: boolean;
        isDisplayInnerSnapDigit?: boolean;
        isDisplaySnapDigit?: boolean;
        maxSnapElementGapDistance?: number;
        maxSnapElementGuidelineDistance?: number;
        onBound?: (e: OnBound) => any;
        onSnap?: (e: OnSnap) => any;
        snapContainer?: MoveableRefType<SVGElement | HTMLElement>;
        snapDigit?: number;
        snapDirections?: boolean | SnapDirections;
        snapDistFormat?: (
            distance: number,
            type: "horizontal" | "vertical",
        ) => string | number;
        snapGap?: boolean;
        snapGridAll?: boolean;
        snapGridHeight?: number;
        snapGridWidth?: number;
        snapHorizontalThreshold?: number;
        snappable?: boolean | string[];
        snapRenderThreshold?: number;
        snapRotationDegrees?: number[];
        snapRotationThreshold?: number;
        snapThreshold?: number;
        snapVerticalThreshold?: number;
        verticalGuidelines?: (string | number | PosGuideline)[];
    }

    Hierarchy (View Summary)

    Index
    bounds?: BoundType | null

    You can set up boundaries.

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

    const moveable = new Moveable(document.body);

    moveable.bounds = { left: 0, right: 1000, top: 0, bottom: 1000};
    elementGuidelines?: (ElementGuidelineValueOption | MoveableRefType<Element>)[]

    Add guidelines for the element.

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

    const moveable = new Moveable(document.body);

    moveable.elementGuidelines = [
    document.querySelector(".element"),
    ];
    elementSnapDirections?: boolean | SnapDirections

    You can specify the snap directions of elements.

    true (true is all directions)
    
    import Moveable from "@moveable-next/vanilla";

    const moveable = new Moveable(document.body, {
    snappable: true,
    elementSnapDirections: true,
    });
    // snap center
    moveable.elementSnapDirections = { left: true, top: true, right: true, bottom: true, center: true, middle: true };
    horizontalGuidelines?: (string | number | PosGuideline)[]

    Add guidelines in the horizontal direction.

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

    const moveable = new Moveable(document.body);

    moveable.horizontalGuidelines = [100, 200, 500];
    innerBounds?: InnerBoundType | null

    You can set up inner boundaries.

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

    const moveable = new Moveable(document.body);

    moveable.innerBounds = { left: 500, top: 500, width: 100, height: 100};
    isDisplayGridGuidelines?: boolean

    Whether to show guideline of snap by grid

    false
    
    isDisplayInnerSnapDigit?: boolean

    Whether to show element inner snap distance

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

    const moveable = new Moveable(document.body);

    moveable.isDisplayInnerSnapDigit = true;
    isDisplaySnapDigit?: boolean

    Whether to show snap distance.

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

    const moveable = new Moveable(document.body);

    moveable.isDisplaySnapDigit = true;
    maxSnapElementGapDistance?: number

    Maximum distance to which element gap guidelines can be snapped.

    Infinity
    
    maxSnapElementGuidelineDistance?: number

    Maximum distance to which element guidelines can be snapped.

    Infinity
    
    onBound?: (e: OnBound) => any

    When the bounds or inner bounds that the target touches while snapping are changed, the bound event is called.

    onSnap?: (e: OnSnap) => any

    When you drag or dragControl, the snap event is called.

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

    const moveable = new Moveable(document.body, {
    snappable: true
    });
    moveable.on("snap", e => {
    console.log("onSnap", e);
    });
    snapContainer?: MoveableRefType<SVGElement | HTMLElement>

    A snap container that is the basis for snap, bounds, and innerBounds.

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

    const moveable = new Moveable(document.querySelector(".container"));

    moveable.snapContainer = document.body;
    snapDigit?: number

    snap distance digits.

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

    const moveable = new Moveable(document.body);

    moveable.snapDigit = 0
    snapDirections?: boolean | SnapDirections

    You can specify the directions to snap to the target.

    true (true is all directions)
    
    import Moveable from "@moveable-next/vanilla";

    const moveable = new Moveable(document.body, {
    snappable: true,
    snapDirections: true,
    });
    // snap center
    moveable.snapDirections = { left: true, top: true, right: true, bottom: true, center: true, middle: true };
    snapDistFormat?: (
        distance: number,
        type: "horizontal" | "vertical",
    ) => string | number

    You can set the text format of the distance shown in the guidelines.

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

    const moveable = new Moveable(document.body, {
    snappable: true,
    snapDistFormat: (v, type) => v,
    });
    moveable.snapDistFormat = (v, type) => `${v}px`;
    snapGap?: boolean

    When you drag, make the gap snap in the element guidelines.

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

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

    moveable.snapGap = false;
    snapGridAll?: boolean

    In the case of a group, if snapGridWidth and snapGridHeight are used, all children can be snapped. Custom fixed directions are not yet allowed. Also, it cannot be applied if rotated.

    false
    
    snapGridHeight?: number

    If height size is greater than 0, you can horizontal snap to the grid.

    0 (0 is not used)
    
    import Moveable from "@moveable-next/vanilla";

    const moveable = new Moveable(document.body);

    moveable.snapGridHeight = 5;
    snapGridWidth?: number

    If width size is greater than 0, you can vertical snap to the grid.

    0 (0 is not used)
    
    import Moveable from "@moveable-next/vanilla";

    const moveable = new Moveable(document.body);

    moveable.snapGridWidth = 5;
    snapHorizontalThreshold?: number

    Distance horizontal between horizontal value that can snap to guidelines.

    5
    
    snappable?: boolean | string[]

    Whether or not target can be snapped to the guideline.

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

    const moveable = new Moveable(document.body);

    moveable.snappable = true;
    snapRenderThreshold?: number

    Distance value that render snapped guidelines.

    1
    
    snapRotationDegrees?: number[]

    degree angles to snap to rotation

    []
    
    snapRotationThreshold?: number

    Snap works if abs(current rotation - snapRotationDegrees) < snapRotationThreshold.

    5
    
    snapThreshold?: number

    /**

    • Distance value that can snap to guidelines.
    • Use snapHorizontalThreshold and snapVerticalThreshold
    0
    *
    * import Moveable from "@moveable-next/vanilla";
    *
    * const moveable = new Moveable(document.body);
    *
    * moveable.snapThreshold = 5;
    snapVerticalThreshold?: number

    Distance Horizontal value that can snap to guidelines.

    5
    
    verticalGuidelines?: (string | number | PosGuideline)[]

    Add guidelines in the vertical direction.

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

    const moveable = new Moveable(document.body);

    moveable.verticalGuidelines = [100, 200, 500];