MCPcopy Index your code
hub / github.com/daybrush/moveable

github.com/daybrush/moveable @0.28.0

repository ↗ · DeepWiki ↗ · release 0.28.0 ↗ · + Follow
1,822 symbols 5,648 edges 386 files 50 documented · 3% 1 cross-repo links updated 2y ago0.53.0 · 2023-12-03★ 10,725449 open issues
README

Moveable

npm version Github actions React Preact Angular Vue Vue 3 Svelte Lit

Moveable is Draggable, Resizable, Scalable, Rotatable, Warpable, Pinchable, Groupable, Snappable

<a href="https://github.com/daybrush/moveable" target="_blank"><strong>Github</strong></a> /
<a href="https://daybrush.com/moveable" target="_blank"><strong>Demo</strong></a> /
<a href="https://daybrush.com/moveable/storybook/" target="_blank"><strong>Storybook</strong></a> /
<a href="https://daybrush.com/moveable/release/latest/doc/" target="_blank"><strong>API</strong></a> /
<a href="https://github.com/daybrush/scena" target="_blank"><strong>Main Project</strong></a>
Moveable
Draggable Resizable Scalable Rotatable
Warpable Pinchable Groupable Snappable
Clippable Roundable OriginDraggable Selecto

🔥 Features

  • Draggable refers to the ability to drag and move targets.
  • Resizable indicates whether the target's width and height can be increased or decreased.
  • Scalable indicates whether the target's x and y can be scale of transform.
  • Rotatable indicates whether the target can be rotated.
  • Warpable indicates whether the target can be warped (distorted, bented).
  • Pinchable indicates whether the target can be pinched with draggable, resizable, scalable, rotatable.
  • Groupable indicates Whether the targets can be moved in group with draggable, resizable, scalable, rotatable.
  • Snappable indicates whether to snap to the guideline.
  • OriginDraggable* indicates Whether to drag origin.
  • Clippable indicates Whether to clip the target.
  • Roundable indicates Whether to show and drag or double click border-radius.
  • Support SVG Elements (svg, path, line, ellipse, g, rect, ...etc)
  • Support Major Browsers
  • Support 3d Transform

⚙️ Installation

npm

$ npm i moveable

scripts

<script src="https://github.com/daybrush/moveable/raw/0.28.0/daybrush.com/moveable/release/latest/dist/moveable.min.js"></script>

📄 Documents

🚀 How to use

  • All classes of moveable control box and able elements have a moveable- prefix. So please don't put moveable- class name in target.
import Moveable from "moveable";

const moveable = new Moveable(document.body, {
    target: document.querySelector(".target"),
    // If the container is null, the position is fixed. (default: parentElement(document.body))
    container: document.body,
    draggable: true,
    resizable: true,
    scalable: true,
    rotatable: true,
    warpable: true,
    // Enabling pinchable lets you use events that
    // can be used in draggable, resizable, scalable, and rotateable.
    pinchable: true, // ["resizable", "scalable", "rotatable"]
    origin: true,
    keepRatio: true,
    // Resize, Scale Events at edges.
    edge: false,
    throttleDrag: 0,
    throttleResize: 0,
    throttleScale: 0,
    throttleRotate: 0,
});
/* draggable */
moveable.on("dragStart", ({ target, clientX, clientY }) => {
    console.log("onDragStart", target);
}).on("drag", ({
    target, transform,
    left, top, right, bottom,
    beforeDelta, beforeDist, delta, dist,
    clientX, clientY,
}) => {
    console.log("onDrag left, top", left, top);
    target!.style.left = `${left}px`;
    target!.style.top = `${top}px`;
    // console.log("onDrag translate", dist);
    // target!.style.transform = transform;
}).on("dragEnd", ({ target, isDrag, clientX, clientY }) => {
    console.log("onDragEnd", target, isDrag);
});

/* resizable */
moveable.on("resizeStart", ({ target, clientX, clientY }) => {
    console.log("onResizeStart", target);
}).on("resize", ({ target, width, height, dist, delta, clientX, clientY }) => {
    console.log("onResize", target);
    delta[0] && (target!.style.width = `${width}px`);
    delta[1] && (target!.style.height = `${height}px`);
}).on("resizeEnd", ({ target, isDrag, clientX, clientY }) => {
    console.log("onResizeEnd", target, isDrag);
});

/* scalable */
moveable.on("scaleStart", ({ target, clientX, clientY }) => {
    console.log("onScaleStart", target);
}).on("scale", ({
    target, scale, dist, delta, transform, clientX, clientY,
}: OnScale) => {
    console.log("onScale scale", scale);
    target!.style.transform = transform;
}).on("scaleEnd", ({ target, isDrag, clientX, clientY }) => {
    console.log("onScaleEnd", target, isDrag);
});

/* rotatable */
moveable.on("rotateStart", ({ target, clientX, clientY }) => {
    console.log("onRotateStart", target);
}).on("rotate", ({ target, beforeDelta, delta, dist, transform, clientX, clientY }) => {
    console.log("onRotate", dist);
    target!.style.transform = transform;
}).on("rotateEnd", ({ target, isDrag, clientX, clientY }) => {
    console.log("onRotateEnd", target, isDrag);
});

/* warpable */
this.matrix = [
    1, 0, 0, 0,
    0, 1, 0, 0,
    0, 0, 1, 0,
    0, 0, 0, 1,
];
moveable.on("warpStart", ({ target, clientX, clientY }) => {
    console.log("onWarpStart", target);
}).on("warp", ({
    target,
    clientX,
    clientY,
    delta,
    dist,
    multiply,
    transform,
}) => {
    console.log("onWarp", target);
    // target.style.transform = transform;
    this.matrix = multiply(this.matrix, delta);
    target.style.transform = `matrix3d(${this.matrix.join(",")})`;
}).on("warpEnd", ({ target, isDrag, clientX, clientY }) => {
    console.log("onWarpEnd", target, isDrag);
});

/* pinchable */
// Enabling pinchable lets you use events that
// can be used in draggable, resizable, scalable, and rotateable.
moveable.on("pinchStart", ({ target, clientX, clientY }) => {
    // pinchStart event occur before dragStart, rotateStart, scaleStart, resizeStart
    console.log("onPinchStart");
}).on("pinch", ({ target, clientX, clientY, datas }) => {
    // pinch event occur before drag, rotate, scale, resize
    console.log("onPinch");
}).on("pinchEnd", ({ isDrag, target, clientX, clientY, datas }) => {
    // pinchEnd event occur before dragEnd, rotateEnd, scaleEnd, resizeEnd
    console.log("onPinchEnd");
});

📦 Packages

  • moveable: A Vanilla Component that create Moveable, Draggable, Resizable, Scalable, Rotatable, Warpable, Pinchable.
  • react-moveable: A React Component that create Moveable, Draggable, Resizable, Scalable, Rotatable, Warpable, Pinchable.
  • preact-moveable: A Preact Component that create Moveable, Draggable, Resizable, Scalable, Rotatable, Warpable, Pinchable.
  • ngx-moveable: An Angular Component that create Moveable, Draggable, Resizable, Scalable, Rotatable, Warpable, Pinchable.
  • svelte-moveable: A Svelte Component that create Moveable, Draggable, Resizable, Scalable, Rotatable, Warpable, Pinchable.
  • lit-moveable: A Lit Component that create Moveable, Draggable, Resizable, Scalable, Rotatable, Warpable, Pinchable.
  • vue-moveable: A Vue Component that create Moveable, Draggable, Resizable, Scalable, Rotatable, Warpable, Pinchable.
  • vue3-moveable: A Vue 3 Component that create Moveable, Draggable, Resizable, Scalable, Rotatable, Warpable, Pinchable.

⚙️ Developments

The `

Extension points exported contracts — how you extend this code

Requester (Interface)
(no doc) [2 implementers]
packages/react-moveable/src/types.ts
StoryParameter (Interface)
(no doc)
storybook/stories/utils/story.tsx
MoveableManager (Interface)
(no doc)
packages/moveable/src/MoveableManager.tsx
LitMoveable (Interface)
(no doc)
packages/lit-moveable/src/LitMoveable.ts
MoveableComponent (Interface)
(no doc)
packages/svelte-moveable/src/lib/index.d.ts
SnappableOptions (Interface)
(no doc)
packages/snappable/src/types.ts
VueMoveableInterface (Interface)
(no doc)
packages/vue-moveable/src/Moveable.vue.d.ts
TargetList (Interface)
(no doc)
packages/helper/src/types.ts

Core symbols most depended-on inside this repo

n
called by 662
demo/static/js/2.8e0d6703.chunk.js
createElement
called by 519
packages/react-moveable/src/types.ts
r
called by 170
demo/static/js/2.8e0d6703.chunk.js
i
called by 160
demo/static/js/2.8e0d6703.chunk.js
a
called by 158
demo/static/js/2.8e0d6703.chunk.js
add
called by 137
packages/react-moveable/stories/utils/story.tsx
s
called by 134
demo/static/js/2.8e0d6703.chunk.js
I
called by 126
demo/static/js/2.8e0d6703.chunk.js

Shape

Function 1,273
Method 270
Interface 221
Class 58

Languages

TypeScript100%

Modules by API surface

demo/static/js/2.8e0d6703.chunk.js447 symbols
packages/react-moveable/src/types.ts257 symbols
packages/react-moveable/src/utils.tsx90 symbols
packages/react-moveable/src/MoveableManager.tsx53 symbols
packages/react-moveable/src/gesto/GestoUtils.ts38 symbols
demo/static/js/main.4efc5ba5.chunk.js33 symbols
packages/react-moveable/src/ables/Snappable.tsx32 symbols
packages/react-moveable/src/ables/Rotatable.tsx24 symbols
packages/helper/src/groups.ts24 symbols
packages/react-moveable/src/InitialMoveable.tsx23 symbols
packages/react-moveable/src/MoveableIndividualGroup.tsx22 symbols
packages/react-moveable/src/ables/Resizable.ts21 symbols

Used by 1 indexed graphs manifest dependencies, hub-wide

Dependencies from manifests, versioned

@angular-devkit/build-angular15.0.4 · 1×
@angular/animations15.0.4 · 1×
@angular/cdk15.0.4 · 1×
@angular/cli15.0.4 · 1×
@angular/common15.2.2 · 1×
@angular/compiler15.2.2 · 1×
@angular/compiler-cli15.0.4 · 1×
@angular/core15.2.2 · 1×
@angular/forms15.0.4 · 1×
@angular/material15.0.4 · 1×
@angular/platform-browser15.2.2 · 1×
@angular/platform-browser-dynamic15.2.2 · 1×

For agents

$ claude mcp add moveable \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact