{"id":15910486,"url":"https://github.com/a7650/vue3-draggable-resizable","last_synced_at":"2025-05-14T23:04:49.650Z","repository":{"id":37294625,"uuid":"311031423","full_name":"a7650/vue3-draggable-resizable","owner":"a7650","description":"[Vue3 组件] 用于拖拽调整位置和大小的的组件，同时支持元素吸附对齐，实时参考线。","archived":false,"fork":false,"pushed_at":"2023-02-11T23:43:58.000Z","size":637,"stargazers_count":683,"open_issues_count":48,"forks_count":134,"subscribers_count":13,"default_branch":"release","last_synced_at":"2025-05-01T03:02:47.828Z","etag":null,"topics":["component","conflict-detection","drag","draggable","refline","resizable","resize","typescript","vue3"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/a7650.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-11-08T09:54:55.000Z","updated_at":"2025-04-26T02:14:01.000Z","dependencies_parsed_at":"2024-06-18T12:40:18.313Z","dependency_job_id":"268dd522-ad6a-454d-b43a-a97efe47d76b","html_url":"https://github.com/a7650/vue3-draggable-resizable","commit_stats":{"total_commits":34,"total_committers":2,"mean_commits":17.0,"dds":0.02941176470588236,"last_synced_commit":"b908f619cb4a307dd3bbaa92e10d3c685e44cf4a"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/a7650%2Fvue3-draggable-resizable","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/a7650%2Fvue3-draggable-resizable/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/a7650%2Fvue3-draggable-resizable/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/a7650%2Fvue3-draggable-resizable/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/a7650","download_url":"https://codeload.github.com/a7650/vue3-draggable-resizable/tar.gz/refs/heads/release","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252423532,"owners_count":21745608,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["component","conflict-detection","drag","draggable","refline","resizable","resize","typescript","vue3"],"created_at":"2024-10-06T15:06:48.066Z","updated_at":"2025-05-14T23:04:44.640Z","avatar_url":"https://github.com/a7650.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\u003cimg src=\"https://github.com/a7650/vue3-draggable-resizable/blob/main/docs/logo.png\" alt=\"logo\"\u003e\u003c/p\u003e\n\n\u003ch1 align=\"center\"\u003eVue3DraggableResizable\u003c/h1\u003e\n\u003cdiv align=\"center\"\u003e\n\n[![npm version](https://badge.fury.io/js/vue3-draggable-resizable.svg)](https://www.npmjs.com/package/vue3-draggable-resizable)\n[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE.md)\n[![npm](https://img.shields.io/npm/dt/vue3-draggable-resizable.svg?style=flat-square)](https://www.npmjs.com/package/vue3-draggable-resizable)\n[![vue version](https://img.shields.io/badge/vue_version-\u003e=3-brightgreen.svg?style=flat-square)](https://github.com/a7650/vue3-draggable-resizable)\n\n\u003c/div\u003e\n\n\u003e [Vue3 组件] 用于拖拽调整位置和大小的的组件，同时支持冲突检测，元素吸附对齐，实时参考线。\n\u003e [ Vue3 Component ] Draggable and resizable component for vue3, and, support element adsorption alignment, real-time reference line, etc.\n\n[点击查看中文文档](https://github.com/a7650/vue3-draggable-resizable/blob/main/docs/document_zh.md)\n\n## Table of Contents\n\n- [Features](#features)\n- [Usage](#Usage)\n  - [Props](#props)\n  - [Events](#events)\n  - [Use adsorption alignment](#Use-adsorption-alignment)\n\n### Features\n\n- Draggable and resizable\n- Define handles for resizing\n- Restrict movement and size in parent node\n- Customize various class names\n- Provide your own markup for handles\n- Adsorption alignment\n- Reference line\n\n### Usage\n\n```bash\n$ npm install vue3-draggable-resizable\n```\n\nRegister the Vue3DraggableResizable\n\n```js\n// \u003emain.js\nimport { createApp } from 'vue'\nimport App from './App.vue'\nimport Vue3DraggableResizable from 'vue3-draggable-resizable'\n//default styles\nimport 'vue3-draggable-resizable/dist/Vue3DraggableResizable.css'\n\n// You will have a global component named \"Vue3DraggableResizable\"\ncreateApp(App)\n  .use(Vue3DraggableResizable)\n  .mount('#app')\n```\n\nYou can also use it separately within the component\n\n```js\n// \u003ecomponent.js\nimport { defineComponent } from 'vue'\nimport Vue3DraggableResizable from 'vue3-draggable-resizable'\n//default styles\nimport 'vue3-draggable-resizable/dist/Vue3DraggableResizable.css'\n\nexport default defineComponent({\n  components: { Vue3DraggableResizable }\n  // ...other\n})\n```\n\nHere is a complete example of using \"vue-template\"\n\n```vue\n\u003ctemplate\u003e\n  \u003cdiv id=\"app\"\u003e\n    \u003cdiv class=\"parent\"\u003e\n      \u003cVue3DraggableResizable\n        :initW=\"110\"\n        :initH=\"120\"\n        v-model:x=\"x\"\n        v-model:y=\"y\"\n        v-model:w=\"w\"\n        v-model:h=\"h\"\n        v-model:active=\"active\"\n        :draggable=\"true\"\n        :resizable=\"true\"\n        @activated=\"print('activated')\"\n        @deactivated=\"print('deactivated')\"\n        @drag-start=\"print('drag-start')\"\n        @resize-start=\"print('resize-start')\"\n        @dragging=\"print('dragging')\"\n        @resizing=\"print('resizing')\"\n        @drag-end=\"print('drag-end')\"\n        @resize-end=\"print('resize-end')\"\n      \u003e\n        This is a test example\n      \u003c/Vue3DraggableResizable\u003e\n    \u003c/div\u003e\n  \u003c/div\u003e\n\u003c/template\u003e\n\n\u003cscript\u003e\nimport { defineComponent } from 'vue'\nimport Vue3DraggableResizable from 'vue3-draggable-resizable'\n//default styles\nimport 'vue3-draggable-resizable/dist/Vue3DraggableResizable.css'\nexport default defineComponent({\n  components: { Vue3DraggableResizable },\n  data() {\n    return {\n      x: 100,\n      y: 100,\n      h: 100,\n      w: 100,\n      active: false\n    }\n  },\n  methods: {\n    print(val) {\n      console.log(val)\n    }\n  }\n})\n\u003c/script\u003e\n\u003cstyle\u003e\n.parent {\n  width: 200px;\n  height: 200px;\n  position: absolute;\n  top: 100px;\n  left: 100px;\n  border: 1px solid #000;\n  user-select: none;\n}\n\u003c/style\u003e\n```\n\n### Props\n\n#### initW\n\ntype: `Number`\u003cbr\u003e\ndefault: `null`\u003cbr\u003e\n\nSet initial width(px)\n\n```html\n\u003cVue3DraggableResizable :initW=\"100\" /\u003e\n```\n\n#### initH\n\ntype: `Number`\u003cbr\u003e\ndefault: `null`\u003cbr\u003e\n\nSet initial height(px)\n\n```html\n\u003cVue3DraggableResizable :initH=\"100\" /\u003e\n```\n\n#### w\n\ntype: `Number`\u003cbr\u003e\ndefault: `0`\u003cbr\u003e\n\nCurrent width(px) of the container.\u003cbr\u003e\nYou can use \"v-model:w\" to keeps it up-to-date\n\n```html\n\u003cVue3DraggableResizable v-model:w=\"100\" /\u003e\n```\n\n#### h\n\ntype: `Number`\u003cbr\u003e\ndefault: `0`\u003cbr\u003e\n\nCurrent height(px) of the container.\u003cbr\u003e\nYou can use \"v-model:h\" to keeps it up-to-date\n\n```html\n\u003cVue3DraggableResizable v-model:h=\"100\" /\u003e\n```\n\n#### x\n\ntype: `Number`\u003cbr\u003e\ndefault: `0`\u003cbr\u003e\n\nCurrent left(px) of the container.\u003cbr\u003e\nYou can use \"v-model:x\" to keeps it up-to-date\n\n```html\n\u003cVue3DraggableResizable v-model:x=\"100\" /\u003e\n```\n\n#### y\n\ntype: `Number`\u003cbr\u003e\ndefault: `0`\u003cbr\u003e\n\nThe current top(px) of the container.\u003cbr\u003e\nYou can use \"v-model:y\" to keeps it up-to-date\n\n```html\n\u003cVue3DraggableResizable v-model:y=\"100\" /\u003e\n```\n\n#### minW\n\ntype: `Number`\u003cbr\u003e\ndefault: `20`\u003cbr\u003e\n\nMinimum width(px)\n\n```html\n\u003cVue3DraggableResizable :minW=\"100\" /\u003e\n```\n\n#### minH\n\ntype: `Number`\u003cbr\u003e\ndefault: `20`\u003cbr\u003e\n\nMinimum height(px)\n\n```html\n\u003cVue3DraggableResizable :minH=\"100\" /\u003e\n```\n\n#### active\n\ntype: `Boolean`\u003cbr\u003e\ndefault: `false`\u003cbr\u003e\n\nIndicates whether the component is selected.\u003cbr\u003e\nYou can use \"v-model:active\" to keeps it up-to-date\n\n```html\n\u003cVue3DraggableResizable v-model:active=\"100\" /\u003e\n```\n\n#### draggable\n\ntype: `Boolean`\u003cbr\u003e\ndefault: `true`\u003cbr\u003e\n\nDefines the component can be draggable or not\n\n```html\n\u003cVue3DraggableResizable :draggable=\"true\" /\u003e\n```\n\n#### resizable\n\ntype: `Boolean`\u003cbr\u003e\ndefault: `true`\u003cbr\u003e\n\nDefines the component can be resizable or not\n\n```html\n\u003cVue3DraggableResizable :draggable=\"true\" /\u003e\n```\n\n#### lockAspectRatio\n\ntype: `Boolean`\u003cbr\u003e\ndefault: `false`\u003cbr\u003e\n\nThe `lockAspectRatio` property is used to lock aspect ratio.\n\n```html\n\u003cVue3DraggableResizable :lockAspectRatio=\"true\" /\u003e\n```\n\n#### disabledX\n\ntype: `Boolean`\u003cbr\u003e\ndefault: `false`\u003cbr\u003e\n\nDefines the component can be moved on x-axis or not\n\n```html\n\u003cVue3DraggableResizable :disabledX=\"true\" /\u003e\n```\n\n#### disabledY\n\ntype: `Boolean`\u003cbr\u003e\ndefault: `false`\u003cbr\u003e\n\nDefines the component can be moved on y-axis or not\n\n```html\n\u003cVue3DraggableResizable :disabledY=\"true\" /\u003e\n```\n\n#### disabledW\n\ntype: `Boolean`\u003cbr\u003e\ndefault: `false`\u003cbr\u003e\n\nDefines the component`s width can be modify or not\n\n```html\n\u003cVue3DraggableResizable :disabledW=\"true\" /\u003e\n```\n\n#### disabledH\n\ntype: `Boolean`\u003cbr\u003e\ndefault: `false`\u003cbr\u003e\n\nDefines the component`s height can be modify or not\n\n```html\n\u003cVue3DraggableResizable :disabledH=\"true\" /\u003e\n```\n\n#### parent\n\ntype: `Boolean`\u003cbr\u003e\ndefault: `false`\u003cbr\u003e\n\nRestrict movement and size within its parent node\n\n```html\n\u003cVue3DraggableResizable :parent=\"true\" /\u003e\n```\n\n#### handles\n\ntype: `Array`\u003cbr\u003e\ndefault: `['tl', 'tm', 'tr', 'ml', 'mr', 'bl', 'bm', 'br']`\n\nDefine the array of handles to restrict the element resizing\n\n- `tl` : Top left\n- `tm` : Top middle\n- `tr` : Top right\n- `mr` : Middle right\n- `ml` : Middle left\n- `bl` : Bottom left\n- `bm` : Bottom middle\n- `br` : Bottom right\n\n```html\n\u003cVue3DraggableResizable :handles=\"['tl','tr','bl','br']\" /\u003e\n```\n\n#### classNameDraggable\n\ntype: `String`\u003cbr\u003e\ndefault: `draggable`\n\nUsed to set the custom `class` of a draggable-resizable component when `draggable` is enable.\n\n```html\n\u003cVue3DraggableResizable classNameDraggable=\"draggable\" /\u003e\n```\n\n#### classNameResizable\n\ntype: `String`\u003cbr\u003e\ndefault: `resizable`\n\nUsed to set the custom `class` of a draggable-resizable component when `resizable` is enable.\n\n```html\n\u003cVue3DraggableResizable classNameResizable=\"resizable\" /\u003e\n```\n\n#### classNameDragging\n\ntype: `String`\u003cbr\u003e\ndefault: `dragging`\n\nUsed to set the custom `class` of a draggable-resizable component when is dragging.\n\n```html\n\u003cVue3DraggableResizable classNameDragging=\"dragging\" /\u003e\n```\n\n#### classNameResizing\n\ntype: `String`\u003cbr\u003e\ndefault: `resizing`\n\nUsed to set the custom `class` of a draggable-resizable component when is resizing.\n\n```html\n\u003cVue3DraggableResizable classNameResizing=\"resizing\" /\u003e\n```\n\n#### classNameActive\n\ntype: `String`\u003cbr\u003e\ndefault: `active`\n\nUsed to set the custom `class` of a draggable-resizable component when is active.\n\n```html\n\u003cVue3DraggableResizable classNameActive=\"active\" /\u003e\n```\n\n#### classNameHandle\n\ntype: `String`\u003cbr\u003e\ndefault: `handle`\n\nUsed to set the custom common `class` of each handle element.\n\n```html\n\u003cVue3DraggableResizable classNameHandle=\"my-handle\" /\u003e\n```\n\nfollowing handle nodes will be rendered\n\n```html\n...\n\u003cdiv class=\"vdr-handle vdr-handle-tl my-handle my-handle-tl\"\u003e\u003c/div\u003e\n\u003cdiv class=\"vdr-handle vdr-handle-tm my-handle my-handle-tm\"\u003e\u003c/div\u003e\n\u003cdiv class=\"vdr-handle vdr-handle-tr my-handle my-handle-tr\"\u003e\u003c/div\u003e\n\u003cdiv class=\"vdr-handle vdr-handle-ml my-handle my-handle-mr\"\u003e\u003c/div\u003e\n...\n```\n\n### Events\n\n#### activated\n\npayload: `-`\n\n```html\n\u003cVue3DraggableResizable @activated=\"activatedHandle\" /\u003e\n```\n\n#### deactivated\n\npayload: `-`\n\n```html\n\u003cVue3DraggableResizable @deactivated=\"deactivatedHandle\" /\u003e\n```\n\n#### drag-start\n\npayload: `{ x: number, y: number }`\n\n```html\n\u003cVue3DraggableResizable @drag-start=\"dragStartHandle\" /\u003e\n```\n\n#### dragging\n\npayload: `{ x: number, y: number }`\n\n```html\n\u003cVue3DraggableResizable @dragging=\"dragStartHandle\" /\u003e\n```\n\n#### drag-end\n\npayload: `{ x: number, y: number }`\n\n```html\n\u003cVue3DraggableResizable @drag-end=\"dragEndHandle\" /\u003e\n```\n\n#### resize-start\n\npayload: `{ x: number, y: number, w: number, h: number }`\n\n```html\n\u003cVue3DraggableResizable @resize-start=\"resizeStartHandle\" /\u003e\n```\n\n#### resizing\n\npayload: `{ x: number, y: number, w: number, h: number }v`\n\n```html\n\u003cVue3DraggableResizable @resizing=\"resizingHandle\" /\u003e\n```\n\n#### resize-end\n\npayload: `{ x: number, y: number, w: number, h: number }`\n\n```html\n\u003cVue3DraggableResizable @resize-end=\"resizeEndHandle\" /\u003e\n```\n\n### Use-adsorption-alignment\n\nYou need to import another component to use the \"adsorption alignment\" feature.\n\nThis can be used as follows.\n\n```vue\n\u003ctemplate\u003e\n  \u003cdiv id=\"app\"\u003e\n    \u003cdiv class=\"parent\"\u003e\n      \u003cDraggableContainer\u003e\n        \u003cVue3DraggableResizable\u003e\n          Test\n        \u003c/Vue3DraggableResizable\u003e\n        \u003cVue3DraggableResizable\u003e\n          Another test\n        \u003c/Vue3DraggableResizable\u003e\n      \u003c/DraggableContainer\u003e\n    \u003c/div\u003e\n  \u003c/div\u003e\n\u003c/template\u003e\n\n\u003cscript\u003e\nimport { defineComponent } from 'vue'\nimport Vue3DraggableResizable from 'vue3-draggable-resizable'\n// This component is not exported by default\n// If you used \"app.use(Vue3DraggableResizable)\"，then you don't need to import it, you can use it directly.\nimport { DraggableContainer } from 'vue3-draggable-resizable'\n//default styles\nimport 'vue3-draggable-resizable/dist/Vue3DraggableResizable.css'\nexport default defineComponent({\n  components: { Vue3DraggableResizable, DraggableContainer }\n})\n\u003c/script\u003e\n\u003cstyle\u003e\n.parent {\n  width: 200px;\n  height: 200px;\n  position: absolute;\n  top: 100px;\n  left: 100px;\n  border: 1px solid #000;\n  user-select: none;\n}\n\u003c/style\u003e\n```\n\n### DraggableContainer Props\n\nThese props apply to DraggableContainer\n\n#### disabled\n\ntype: `Boolean`\u003cbr\u003e\ndefault: `false`\u003cbr\u003e\n\nDisable this feature\n\n```html\n\u003cDraggableContainer :disabled=\"true\"\u003e\n  \u003cVue3DraggableResizable\u003e\n    Test\n  \u003c/Vue3DraggableResizable\u003e\n  \u003cVue3DraggableResizable\u003e\n    Another test\n  \u003c/Vue3DraggableResizable\u003e\n\u003c/DraggableContainer\u003e\n```\n\n#### adsorbParent\n\ntype: `Boolean`\u003cbr\u003e\ndefault: `true`\u003cbr\u003e\n\nAdsorption near parent component\n\n```html\n\u003cDraggableContainer :adsorbParent=\"false\"\u003e\n  \u003cVue3DraggableResizable\u003e\n    Test\n  \u003c/Vue3DraggableResizable\u003e\n  \u003cVue3DraggableResizable\u003e\n    Another test\n  \u003c/Vue3DraggableResizable\u003e\n\u003c/DraggableContainer\u003e\n```\n\n#### adsorbCols\n\ntype: `Array\u003cNumber\u003e`\u003cbr\u003e\ndefault: `null`\u003cbr\u003e\n\nCustom guides(column)\n\n```html\n\u003cDraggableContainer :adsorbCols=\"[10,20,30]\"\u003e\n  \u003cVue3DraggableResizable\u003e\n    Test\n  \u003c/Vue3DraggableResizable\u003e\n  \u003cVue3DraggableResizable\u003e\n    Another test\n  \u003c/Vue3DraggableResizable\u003e\n\u003c/DraggableContainer\u003e\n```\n\n#### adsorbRows\n\ntype: `Array\u003cNumber\u003e`\u003cbr\u003e\ndefault: `null`\u003cbr\u003e\n\nCustom guides(row)\n\n```html\n\u003cDraggableContainer :adsorbRows=\"[10,20,30]\"\u003e\n  \u003cVue3DraggableResizable\u003e\n    Test\n  \u003c/Vue3DraggableResizable\u003e\n  \u003cVue3DraggableResizable\u003e\n    Another test\n  \u003c/Vue3DraggableResizable\u003e\n\u003c/DraggableContainer\u003e\n```\n\n#### referenceLineVisible\n\ntype: `Boolean`\u003cbr\u003e\ndefault: `true`\u003cbr\u003e\n\nreference line visible\n\n```html\n\u003cDraggableContainer :referenceLineVisible=\"false\"\u003e\n  \u003cVue3DraggableResizable\u003e\n    Test\n  \u003c/Vue3DraggableResizable\u003e\n  \u003cVue3DraggableResizable\u003e\n    Another test\n  \u003c/Vue3DraggableResizable\u003e\n\u003c/DraggableContainer\u003e\n```\n\n#### referenceLineColor\n\ntype: `String`\u003cbr\u003e\ndefault: `#f00`\u003cbr\u003e\n\nreference line color\n\n```html\n\u003cDraggableContainer :referenceLineColor=\"#0f0\"\u003e\n  \u003cVue3DraggableResizable\u003e\n    Test\n  \u003c/Vue3DraggableResizable\u003e\n  \u003cVue3DraggableResizable\u003e\n    Another test\n  \u003c/Vue3DraggableResizable\u003e\n\u003c/DraggableContainer\u003e\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fa7650%2Fvue3-draggable-resizable","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fa7650%2Fvue3-draggable-resizable","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fa7650%2Fvue3-draggable-resizable/lists"}