Moveable
    Preparing search index...

    Interface MoveableManagerInterface<T, U>

    interface MoveableManagerInterface<T = {}, U = {}> {
        areaElement: HTMLElement;
        controlAbles: Able<IObject<any>, IObject<any>>[];
        controlBox: HTMLElement;
        controlGesto: Gesto;
        enabledAbles: Able<IObject<any>, IObject<any>>[];
        isUnmounted: boolean;
        moveables?: MoveableManagerInterface<{}, {}>[];
        props: MoveableManagerProps<T>;
        renderState: Record<string, any>;
        rotation: number;
        scale: number[];
        state: MoveableManagerState<U>;
        targetAbles: Able<IObject<any>, IObject<any>>[];
        targetGesto: Gesto;
        destroy(): void;
        dragStart(e: MouseEvent | TouchEvent, target?: EventTarget | null): void;
        forceUpdate(callback?: () => any): any;
        getAble<T extends Able<IObject<any>, IObject<any>>>(
            ableName: string,
        ): T | undefined;
        getContainer(): SVGElement | HTMLElement;
        getControlBoxElement(): HTMLElement;
        getDragElement(): SVGElement | HTMLElement | null | undefined;
        getManager(): MoveableManagerInterface<any, any>;
        getMoveables(): MoveableManagerInterface<{}, {}>[];
        getRect(): RectInfo;
        getRotation(): number;
        getState(): MoveableManagerState<U>;
        getTargets(): (SVGElement | HTMLElement)[];
        hitTest(el: Element | HitRect): number;
        isDragging(ableName?: string): boolean;
        isInside(clientX: number, clientY: number): boolean;
        isMoveableElement(target: Element): boolean;
        request<
            RequestParam extends AbleRequestParam,
            Name extends string = string,
        >(
            ableName: Name,
            params?: RequestParam,
            isInstant?: boolean,
        ): Requester<RequestParam>;
        setState(state: any, callback?: () => any): any;
        stopDrag(type?: "target" | "control"): void;
        triggerEvent(name: string, params: IObject<any>, isManager?: boolean): any;
        updateRect(
            type?: "" | "Start" | "End",
            isTarget?: boolean,
            isSetState?: boolean,
        ): void;
        updateSelectors(): void;
        updateTarget(): void;
        useCSS(tag: string, css: string): any;
        waitToChangeTarget(): Promise<void>;
    }

    Type Parameters

    • T = {}
    • U = {}

    Hierarchy (View Summary)

    Index
    areaElement: HTMLElement
    controlAbles: Able<IObject<any>, IObject<any>>[]
    controlBox: HTMLElement
    controlGesto: Gesto
    enabledAbles: Able<IObject<any>, IObject<any>>[]
    isUnmounted: boolean
    moveables?: MoveableManagerInterface<{}, {}>[]
    renderState: Record<string, any>
    rotation: number
    scale: number[]
    targetAbles: Able<IObject<any>, IObject<any>>[]
    targetGesto: Gesto
    • You can drag start the Moveable through the external MouseEventor TouchEvent. (Angular: ngDragStart)

      Parameters

      • e: MouseEvent | TouchEvent

        external MouseEventor TouchEvent

      • Optionaltarget: EventTarget | null

      Returns void

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

      const moveable = new Moveable(document.body);

      document.body.addEventListener("mousedown", e => {
      if (!moveable.isMoveableElement(e.target)) {
      moveable.dragStart(e);
      }
      });
    • Get targets set in moveable through target or targets of props.

      Returns (SVGElement | HTMLElement)[]

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

      const moveable = new Moveable(document.body, {
      target: [targetRef, ".target", document.querySelectorAll(".target")],
      });

      console.log(moveable.getTargets());
    • Hit test an element or rect on a moveable target. (100% = 100)

      Parameters

      • el: Element | HitRect

        element or rect to test

      Returns number

      Get hit test rate (rate > 0 is hitted)

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

      const moveable = new Moveable(document.body);

      document.body.addEventListener("mousedown", e => {
      if (moveable.hitTest(e.target) > 0) {
      console.log("hiited");
      }
      });
    • Check if the moveable state is being dragged.

      Parameters

      • OptionalableName: string

        If you want to check if able is dragging, specify ableName.

      Returns boolean

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

      const moveable = new Moveable(document.body);

      // false
      console.log(moveable.isDragging());

      moveable.on("drag", () => {
      // true
      console.log(moveable.isDragging());
      });
    • Whether the coordinates are inside Moveable

      Parameters

      • clientX: number

        x coordinate

      • clientY: number

        y coordinate

      Returns boolean

      True if the coordinate is in moveable or false

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

      const moveable = new Moveable(document.body);

      document.body.addEventListener("mousedown", e => {
      if (moveable.isInside(e.clientX, e.clientY)) {
      console.log("inside");
      }
      });
    • Check if the target is an element included in the moveable.

      Parameters

      • target: Element

        the target

      Returns boolean

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

      const moveable = new Moveable(document.body);

      window.addEventListener("click", e => {
      if (!moveable.isMoveableElement(e.target)) {
      moveable.target = e.target;
      }
      });
    • You can stop the dragging currently in progress through a method from outside.

      Parameters

      • Optionaltype: "target" | "control"

      Returns void

      The Rect Info

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

      const moveable = new Moveable(document.body);

      moveable.stopDrag();
    • Parameters

      • name: string
      • params: IObject<any>
      • OptionalisManager: boolean

      Returns any

    • If the location or size of the target is changed, call the .updateRect() method. Use the useResizeObserver and useMutationObserver props to update automatically.

      If the width, height, left, and top of all elements change, update the shape of the moveable.

      Parameters

      • Optionaltype: "" | "Start" | "End"
      • OptionalisTarget: boolean
      • OptionalisSetState: boolean

      Returns void

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

      const moveable = new Moveable(document.body);

      window.addEventListener("resize", e => {
      moveable.updateRect();
      });
    • If the element list corresponding to the selector among the targets is changed, it is updated.

      Returns void

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

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

      moveable.updateSelectors();
    • If the width, height, left, and top of the only target change, update the shape of the moveable. Use .updateRect() method

      Returns void

      Use .updateRect() method

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

      const moveable = new Moveable(document.body);

      moveable.updateTarget();
    • User changes target and waits for target to change.

      Returns Promise<void>

      document.querySelector(".target").addEventListener("mousedown", e => {
      moveable.waitToChangeTarget().then(() => {
      moveable.dragStart(e, e.currentTarget);
      });
      moveable.target = e.currentTarget;
      });