moveable

moveable

功能丰富的Web元素交互控制库

Moveable是一个强大的JavaScript库,为Web元素提供多样化的交互控制能力。该库支持拖拽、缩放、旋转、扭曲等基本操作,并兼容React、Vue、Angular等主流框架。Moveable还具备分组、对齐、裁剪等高级功能,有助于实现复杂的界面交互效果。其设计灵活,文档完善,便于开发者快速集成和使用。

Moveable组件库拖拽缩放旋转变形Github开源项目
<p align="middle"><img src="https://yellow-cdn.veclightyear.com/835a84d5/d5dca401-8a22-4152-9195-ea7945f51701.png"/></p> <h2 align="middle">Moveable</h2> <p align="middle"> <a href="https://opencollective.com/moveable" alt="Open Collective上的财务贡献者"><img src="https://yellow-cdn.veclightyear.com/835a84d5/67716115-8b28-4f4e-bd88-727db20658d5.svg?label=financial+contributors" /></a> <a href="https://www.npmjs.com/package/moveable" target="_blank"><img src="https://yellow-cdn.veclightyear.com/835a84d5/83a10560-c634-4bd2-bf0b-bbe40130708b.svg?style=flat-square&color=007acc&label=version" alt="npm版本" /></a> <a href="https://github.com/daybrush/moveable/actions" target="_blank"><img alt="Github actions" src="https://img.shields.io/github/actions/workflow/status/daybrush/moveable/run-e2e.yml?branch=master&style=flat-square" /></a> <img src="https://yellow-cdn.veclightyear.com/835a84d5/063fe87e-5606-4b56-a4c5-19a39585be9e.svg?style=flat-square"/> <a href="https://github.com/daybrush/moveable/blob/master/LICENSE" target="_blank"><img src="https://yellow-cdn.veclightyear.com/835a84d5/9c06a62a-cb38-418a-8b2a-897dc41bf6db.svg?style=flat-square&label=license&color=08CE5D"/></a> <a href="https://github.com/daybrush/moveable/tree/master/packages/react-moveable" target="_blank"> <img alt="React" src="https://yellow-cdn.veclightyear.com/835a84d5/fc0889e8-4a1e-4fed-9342-e7b029259ada.svg?label=&message=React&style=flat-square&color=61daeb" /></a> <a href="https://github.com/daybrush/moveable/tree/master/packages/preact-moveable" target="_blank"><img alt="Preact" src="https://yellow-cdn.veclightyear.com/835a84d5/fc0889e8-4a1e-4fed-9342-e7b029259ada.svg?label=&message=Preact&style=flat-square&color=673ab8" /></a> <a href="https://github.com/daybrush/moveable/tree/master/packages/ngx-moveable" target="_blank"><img alt="Angular" src="https://yellow-cdn.veclightyear.com/835a84d5/fc0889e8-4a1e-4fed-9342-e7b029259ada.svg?label=&message=Angular&style=flat-square&color=C82B38" /></a> <a href="https://github.com/daybrush/moveable/tree/master/packages/vue-moveable" target="_blank"><img alt="Vue" src="https://yellow-cdn.veclightyear.com/835a84d5/fc0889e8-4a1e-4fed-9342-e7b029259ada.svg?label=&message=Vue&style=flat-square&color=3fb984" /></a> <a href="https://github.com/daybrush/moveable/tree/master/packages/vue3-moveable" target="_blank"><img alt="Vue 3" src="https://yellow-cdn.veclightyear.com/835a84d5/fc0889e8-4a1e-4fed-9342-e7b029259ada.svg?label=&message=Vue%203&style=flat-square&color=3fb984" /></a> <a href="https://github.com/daybrush/moveable/tree/master/packages/svelte-moveable" target="_blank"><img alt="Svelte" src="https://yellow-cdn.veclightyear.com/835a84d5/fc0889e8-4a1e-4fed-9342-e7b029259ada.svg?label=&message=Svelte&style=flat-square&color=C82B38" /></a> <a href="https://github.com/daybrush/moveable/tree/master/packages/lit-moveable" target="_blank"><img alt="Lit" src="https://yellow-cdn.veclightyear.com/835a84d5/fc0889e8-4a1e-4fed-9342-e7b029259ada.svg?label=&message=Lit&style=flat-square&color=61daeb" /></a> </p> <p align="middle">Moveable是可拖动、可调整大小、可缩放、可旋转、可扭曲、可捏合、可分组、可对齐的组件</p> <p align="middle"> <a href="https://github.com/daybrush/moveable" target="_blank"><strong>Github</strong></a> / <a href="https://daybrush.com/moveable" target="_blank"><strong>演示</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>主项目</strong></a> </p> <table width="100%" align="center"> <tr> <th colspan="4">可移动</th> </tr> <tr> <td align="center"><a href="https://daybrush.com/moveable/storybook/index.html?path=/story/basic--basic-draggable"><strong>可拖拽</strong></a></td> <td align="center"><a href="https://daybrush.com/moveable/storybook/index.html?path=/story/basic--basic-resizable"><strong>可调整大小</strong></a></td> <td align="center"><a href="https://daybrush.com/moveable/storybook/index.html?path=/story/basic--basic-scalable"><strong>可缩放</strong></a></td> <td align="center"><a href="https://daybrush.com/moveable/storybook/index.html?path=/story/basic--basic-rotatable"><strong>可旋转</strong></a></td> </tr> <tr> <td align="center"> <img src="https://yellow-cdn.veclightyear.com/835a84d5/ca9dc1d3-eac2-4173-8ef7-129b2ba06f2f.gif" /> </td> <td align="center"> <img src="https://yellow-cdn.veclightyear.com/835a84d5/ec6d7f90-42fb-45ca-95f4-9f6560a79c19.gif" /> </td> <td align="center"> <img src="https://yellow-cdn.veclightyear.com/835a84d5/fae17229-1f88-4144-a7ea-0d157b234c63.gif" /> </td> <td align="center"> <img src="https://yellow-cdn.veclightyear.com/835a84d5/626df8f0-1223-4da7-aeb7-07e40dedb1a1.gif" /> </td> </tr> <tr> <td align="center"><a href="https://daybrush.com/moveable/storybook/index.html?path=/story/basic--basic-warpable"><strong>可变形</strong></a></td> <td align="center"><a href="https://daybrush.com/moveable/release/latest/doc/Moveable.Pinchable.html"><strong>可捏合</strong></a></td> <td align="center"><a href="https://daybrush.com/moveable/storybook/index.html?path=/story/group--group-draggable-resizable-rotatable"><strong>可分组</strong></a></td> <td align="center"><a href="https://daybrush.com/moveable/storybook/index.html?path=/story/snap-bound--snap-guidelines"><strong>可对齐</strong></a></td> </tr> <tr> <td align="center"><img src="https://yellow-cdn.veclightyear.com/835a84d5/3755d63a-08e6-4971-941a-580ca12ee085.gif"/></td> <td align="center"><img src="https://yellow-cdn.veclightyear.com/835a84d5/f7239682-b3b5-4e0f-8151-308eb7c2960b.gif"/></td> <td align="center"><img src="https://yellow-cdn.veclightyear.com/835a84d5/48beacaf-2b84-4657-b061-d03bed399a70.gif"/></td> <td align="center"><img src="https://yellow-cdn.veclightyear.com/835a84d5/f6252a3c-c639-48d4-91e9-b63bb75d70c6.gif"/></td> </tr> <tr> <td align="center"><a href="https://daybrush.com/moveable/storybook/index.html?path=/story/basic--basic-clippable"><strong>可裁剪</strong></a></td> <td align="center"><a href="https://daybrush.com/moveable/storybook/index.html?path=/story/basic--basic-roundable"><strong>可圆角</strong></a></td> <td align="center"><a href="https://daybrush.com/moveable/storybook/index.html?path=/story/basic--basic-origin-draggable"><strong>可拖动原点</strong></a></td> <td align="center"><a href="https://github.com/daybrush/selecto"><strong>可选择</strong></a></td> </tr> <tr> <td align="center"><img src="https://yellow-cdn.veclightyear.com/835a84d5/14c0912a-9ed4-4c31-8008-9d8ca8f217f0.gif"/></td> <td align="center"><img src="https://yellow-cdn.veclightyear.com/835a84d5/ef9480e5-d8ee-48c9-995e-b5171b24bced.gif"/></td> <td align="center"><img src="https://yellow-cdn.veclightyear.com/835a84d5/d06470dd-27fa-425e-ba60-6035dd58856b.gif"/></td> <td align="center"><img src="https://yellow-cdn.veclightyear.com/835a84d5/4408da7a-3d39-4300-a888-154b778617a6.gif"/></td> </tr> </table>

🔥 特性

  • 可拖拽指的是可以拖动和移动目标。
  • 可调整大小表示可以增加或减少目标的宽度和高度。
  • 可缩放表示可以缩放目标的 x 和 y 变换。
  • 可旋转表示目标可以被旋转。
  • 可变形表示目标可以被扭曲(变形、弯曲)。
  • 可捏合表示目标可以通过拖拽、调整大小、缩放、旋转进行捏合操作。
  • 可分组表示目标可以作为一组进行拖拽、调整大小、缩放、旋转。
  • 可对齐表示是否可以对齐到指导线。
  • 可拖动原点表示是否可以拖动原点。
  • 可裁剪表示是否可以裁剪目标。
  • 可圆角表示是否可以显示和拖动或双击边框圆角。
  • 支持 SVG 元素(svg、path、line、ellipse、g、rect等)
  • 支持主流浏览器
  • 支持 3D 变换

⚙️ 安装

npm

$ npm i moveable

scripts

<script src="//daybrush.com/moveable/release/latest/dist/moveable.min.js"></script>

📄 文档

🚀 如何使用

  • Moveable 控制框和功能元素的所有类都有 moveable- 前缀。因此请不要在目标元素上使用 moveable- 类名。
import Moveable from "moveable"; const moveable = new Moveable(document.body, { target: document.querySelector(".target"), // 如果容器为null,则位置是固定的。(默认值:parentElement(document.body)) container: document.body, draggable: true, resizable: true, scalable: true, rotatable: true, warpable: true, // 启用pinchable可以使用在draggable、resizable、scalable和rotateable中使用的事件。 pinchable: true, // ["resizable", "scalable", "rotatable"] origin: true, keepRatio: true, // 在边缘进行Resize、Scale事件。 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 */ // 启用pinchable可以使用在draggable、resizable、scalable和rotateable中使用的事件。 moveable.on("pinchStart", ({ target, clientX, clientY }) => { // pinchStart事件发生在dragStart、rotateStart、scaleStart、resizeStart之前 console.log("onPinchStart"); }).on("pinch", ({ target, clientX, clientY, datas }) => { // pinch事件发生在drag、rotate、scale、resize之前 console.log("onPinch"); }).on("pinchEnd", ({ isDrag, target, clientX, clientY, datas }) => { // pinchEnd事件发生在dragEnd、rotateEnd、scaleEnd、resizeEnd之前 console.log("onPinchEnd"); });

📦 包

  • moveable:一个创建可移动、可拖动、可调整大小、可缩放、可旋转、可变形、可捏拉的原生组件。
  • react-moveable:一个创建可移动、可拖动、可调整大小、可缩放、可旋转、可变形、可捏拉的React组件。
  • preact-moveable:一个创建可移动、可拖动、可调整大小、可缩放、可旋转、可变形、可捏拉的Preact组件。
  • ngx-moveable:一个创建可移动、可拖动、可调整大小、可缩放、可旋转、可变形、可捏拉的Angular组件。
  • svelte-moveable:一个创建可移动、可拖动、可调整大小、可缩放、可旋转、可变形、可捏拉的Svelte组件。
  • lit-moveable:一个创建可移动、可拖动、可调整大小、可缩放、可旋转、可变形、可捏拉的Lit组件。
  • vue-moveable:一个创建可移动、可拖动、可调整大小、可缩放、可旋转、可变形、可捏拉的Vue组件。
  • vue3-moveable:一个创建可移动、可拖动、可调整大小、可缩放、可旋转、可变形、可捏拉的Vue 3组件。

⚙️ 开发

moveable仓库使用yarn作为monorepo进行管理。

yarn config set registry https://registry.npmjs.org/

主项目是用react制作的,我使用croact来使其在umd中更轻量。

开发和测试请查看packages/react-moveable

npm run storybook

$ yarn
$ npm run packages:build
$ npm run storybook

在开发模式下运行应用。<br/> 打开http://localhost:6006在浏览器中查看。

如果你进行编辑,页面将重新加载。<br/> 你还将在控制台中看到任何lint错误。

⭐️ 支持我们

如果这个项目对你有帮助,请给个⭐️!

👏 贡献

如果你有任何问题或请求,或想为moveable或其他包做出贡献,请随时在issue中提出或给我一个Pull Request。

代码贡献者

这个项目的存在要感谢所有做出贡献的人。[贡献]。

<a href="https://github.com/daybrush/moveable/graphs/contributors"> <img src="https://contrib.rocks/image?repo=daybrush/moveable" /> </a>

🐞 错误报告

如果你发现了错误,请通过在GitHub上开启新的Issue来向我们报告。

赞助商

<p align="center"> <a href="https://yellow-cdn.veclightyear.com/835a84d5/bd666f17-4b92-4135-8afa-ec7a871224ff.svg"> <img src="https://yellow-cdn.veclightyear.com/835a84d5/bd666f17-4b92-4135-8afa-ec7a871224ff.svg"/> </a> </p>

Open Collective财务贡献者

成为财务贡献者,帮助我们维持我们的社区。[贡献]

个人

<a href="https://opencollective.com/moveable"><img src="https://yellow-cdn.veclightyear.com/835a84d5/d774f2d9-22cf-4d14-aaa8-621d46d4d71b.svg?width=890" /></a>

组织

通过您的组织支持这个项目。您的logo将在此处显示,并链接到您的网站。[贡献]

<a href="https://opencollective.com/moveable/organization/0/website"><img src="https://yellow-cdn.veclightyear.com/835a84d5/50302236-7a35-4e23-bb58-f493ed3615ed.svg"/></a> <a href="https://opencollective.com/moveable/organization/1/website"><img src="https://yellow-cdn.veclightyear.com/835a84d5/0d82bf3b-d43f-4267-9e5c-6f0df09cd1b2.svg"/></a> <a href="https://opencollective.com/moveable/organization/2/website"><img src="https://yellow-cdn.veclightyear.com/835a84d5/fe4d68bd-98d8-4bae-b295-cfaef50a6dac.svg"/></a> <a href="https://opencollective.com/moveable/organization/3/website"><img src="https://yellow-cdn.veclightyear.com/835a84d5/ad3dec80-6bdf-4377-a204-18400156a154.svg"/></a> <a href="https://opencollective.com/moveable/organization/4/website"><img src="https://yellow-cdn.veclightyear.com/835a84d5/bc7e9650-a154-4f54-9800-c15fa3af56db.svg"/></a> <a href="https://opencollective.com/moveable/organization/5/website"><img src="https://yellow-cdn.veclightyear.com/835a84d5/91e1aaca-d5a6-42a0-922f-fdb403595711.svg"/></a> <a href="https://opencollective.com/moveable/organization/6/website"><img src="https://yellow-cdn.veclightyear.com/835a84d5/28bc0c56-efe2-440e-ad10-4b943307840b.svg"/></a> <a href="https://opencollective.com/moveable/organization/7/website"><img src="https://yellow-cdn.veclightyear.com/835a84d5/2322d80c-4408-4bc8-9cff-3641cf7dba4b.svg"/></a> <a href="https://opencollective.com/moveable/organization/8/website"><img src="https://yellow-cdn.veclightyear.com/835a84d5/49ffe9b1-807a-48aa-b01e-b05084ea2dc9.svg"/></a> <a href="https://opencollective.com/moveable/organization/9/website"><img src="https://yellow-cdn.veclightyear.com/835a84d5/571f1b7f-1eff-4e32-a651-c7c3189cd7c5.svg"/></a>

📝 许可证

本项目采用 MIT 许可证。

MIT 许可证

版权所有 (c) 2019 Daybrush

特此免费授予任何获得本软件副本和相关文档文件("软件")的人不受限制地处理本软件的权利,包括但不限于使用、复制、修改、合并、发布、分发、再许可和/或销售软件副本的权利,并允许向其提供本软件的人这样做,但须符合以下条件:

上述版权声明和本许可声明应包含在本软件的所有副本或主要部分中。

本软件按"原样"提供,不附带任何明示或暗示的担保,包括但不限于对适销性、特定用途适用性和非侵权性的担保。在任何情况下,作者或版权持有人均不对任何索赔、损害或其他责任负责,无论是在合同诉讼、侵权行为或其他方面,由软件或软件的使用或其他交易引起或与之相关。

编辑推荐精选

讯飞智文

讯飞智文

一键生成PPT和Word,让学习生活更轻松

讯飞智文是一个利用 AI 技术的项目,能够帮助用户生成 PPT 以及各类文档。无论是商业领域的市场分析报告、年度目标制定,还是学生群体的职业生涯规划、实习避坑指南,亦或是活动策划、旅游攻略等内容,它都能提供支持,帮助用户精准表达,轻松呈现各种信息。

AI办公办公工具AI工具讯飞智文AI在线生成PPTAI撰写助手多语种文档生成AI自动配图热门
讯飞星火

讯飞星火

深度推理能力全新升级,全面对标OpenAI o1

科大讯飞的星火大模型,支持语言理解、知识问答和文本创作等多功能,适用于多种文件和业务场景,提升办公和日常生活的效率。讯飞星火是一个提供丰富智能服务的平台,涵盖科技资讯、图像创作、写作辅助、编程解答、科研文献解读等功能,能为不同需求的用户提供便捷高效的帮助,助力用户轻松获取信息、解决问题,满足多样化使用场景。

热门AI开发模型训练AI工具讯飞星火大模型智能问答内容创作多语种支持智慧生活
Spark-TTS

Spark-TTS

一种基于大语言模型的高效单流解耦语音令牌文本到语音合成模型

Spark-TTS 是一个基于 PyTorch 的开源文本到语音合成项目,由多个知名机构联合参与。该项目提供了高效的 LLM(大语言模型)驱动的语音合成方案,支持语音克隆和语音创建功能,可通过命令行界面(CLI)和 Web UI 两种方式使用。用户可以根据需求调整语音的性别、音高、速度等参数,生成高质量的语音。该项目适用于多种场景,如有声读物制作、智能语音助手开发等。

Trae

Trae

字节跳动发布的AI编程神器IDE

Trae是一种自适应的集成开发环境(IDE),通过自动化和多元协作改变开发流程。利用Trae,团队能够更快速、精确地编写和部署代码,从而提高编程效率和项目交付速度。Trae具备上下文感知和代码自动完成功能,是提升开发效率的理想工具。

AI工具TraeAI IDE协作生产力转型热门
咔片PPT

咔片PPT

AI助力,做PPT更简单!

咔片是一款轻量化在线演示设计工具,借助 AI 技术,实现从内容生成到智能设计的一站式 PPT 制作服务。支持多种文档格式导入生成 PPT,提供海量模板、智能美化、素材替换等功能,适用于销售、教师、学生等各类人群,能高效制作出高品质 PPT,满足不同场景演示需求。

讯飞绘文

讯飞绘文

选题、配图、成文,一站式创作,让内容运营更高效

讯飞绘文,一个AI集成平台,支持写作、选题、配图、排版和发布。高效生成适用于各类媒体的定制内容,加速品牌传播,提升内容营销效果。

热门AI辅助写作AI工具讯飞绘文内容运营AI创作个性化文章多平台分发AI助手
材料星

材料星

专业的AI公文写作平台,公文写作神器

AI 材料星,专业的 AI 公文写作辅助平台,为体制内工作人员提供高效的公文写作解决方案。拥有海量公文文库、9 大核心 AI 功能,支持 30 + 文稿类型生成,助力快速完成领导讲话、工作总结、述职报告等材料,提升办公效率,是体制打工人的得力写作神器。

openai-agents-python

openai-agents-python

OpenAI Agents SDK,助力开发者便捷使用 OpenAI 相关功能。

openai-agents-python 是 OpenAI 推出的一款强大 Python SDK,它为开发者提供了与 OpenAI 模型交互的高效工具,支持工具调用、结果处理、追踪等功能,涵盖多种应用场景,如研究助手、财务研究等,能显著提升开发效率,让开发者更轻松地利用 OpenAI 的技术优势。

Hunyuan3D-2

Hunyuan3D-2

高分辨率纹理 3D 资产生成

Hunyuan3D-2 是腾讯开发的用于 3D 资产生成的强大工具,支持从文本描述、单张图片或多视角图片生成 3D 模型,具备快速形状生成能力,可生成带纹理的高质量 3D 模型,适用于多个领域,为 3D 创作提供了高效解决方案。

3FS

3FS

一个具备存储、管理和客户端操作等多种功能的分布式文件系统相关项目。

3FS 是一个功能强大的分布式文件系统项目,涵盖了存储引擎、元数据管理、客户端工具等多个模块。它支持多种文件操作,如创建文件和目录、设置布局等,同时具备高效的事件循环、节点选择和协程池管理等特性。适用于需要大规模数据存储和管理的场景,能够提高系统的性能和可靠性,是分布式存储领域的优质解决方案。

下拉加载更多