[Vue3 Component] 拖拽缩放并具有自动吸附对齐、参考线等功能
npm install vue3-draggable-resizable




> [Vue3 组件] 用于拖拽调整位置和大小的的组件,同时支持冲突检测,元素吸附对齐,实时参考线。
> [ Vue3 Component ] Draggable and resizable component for vue3, and, support element adsorption alignment, real-time reference line, etc.
- Features
- Usage
- Props
- Events
- Use adsorption alignment
- Draggable and resizable
- Define handles for resizing
- Restrict movement and size in parent node
- Customize various class names
- Provide your own markup for handles
- Adsorption alignment
- Reference line
``bash`
$ npm install vue3-draggable-resizable
Register the Vue3DraggableResizable
`js
// >main.js
import { createApp } from 'vue'
import App from './App.vue'
import Vue3DraggableResizable from 'vue3-draggable-resizable'
//default styles
import 'vue3-draggable-resizable/dist/Vue3DraggableResizable.css'
// You will have a global component named "Vue3DraggableResizable"
createApp(App)
.use(Vue3DraggableResizable)
.mount('#app')
`
You can also use it separately within the component
`js
// >component.js
import { defineComponent } from 'vue'
import Vue3DraggableResizable from 'vue3-draggable-resizable'
//default styles
import 'vue3-draggable-resizable/dist/Vue3DraggableResizable.css'
export default defineComponent({
components: { Vue3DraggableResizable }
// ...other
})
`
Here is a complete example of using "vue-template"
`vue
:initH="120"
v-model:x="x"
v-model:y="y"
v-model:w="w"
v-model:h="h"
v-model:active="active"
:draggable="true"
:resizable="true"
@activated="print('activated')"
@deactivated="print('deactivated')"
@drag-start="print('drag-start')"
@resize-start="print('resize-start')"
@dragging="print('dragging')"
@resizing="print('resizing')"
@drag-end="print('drag-end')"
@resize-end="print('resize-end')"
>
This is a test example
`
#### initW
type: Numbernull
default:
Set initial width(px)
`html`
#### initH
type: Numbernull
default:
Set initial height(px)
`html`
#### w
type: Number0
default:
Current width(px) of the container.
You can use "v-model:w" to keeps it up-to-date
`html`
#### h
type: Number0
default:
Current height(px) of the container.
You can use "v-model:h" to keeps it up-to-date
`html`
#### x
type: Number0
default:
Current left(px) of the container.
You can use "v-model:x" to keeps it up-to-date
`html`
#### y
type: Number0
default:
The current top(px) of the container.
You can use "v-model:y" to keeps it up-to-date
`html`
#### minW
type: Number20
default:
Minimum width(px)
`html`
#### minH
type: Number20
default:
Minimum height(px)
`html`
#### active
type: Booleanfalse
default:
Indicates whether the component is selected.
You can use "v-model:active" to keeps it up-to-date
`html`
#### draggable
type: Booleantrue
default:
Defines the component can be draggable or not
`html`
#### resizable
type: Booleantrue
default:
Defines the component can be resizable or not
`html`
#### lockAspectRatio
type: Booleanfalse
default:
The lockAspectRatio property is used to lock aspect ratio.
`html`
#### disabledX
type: Booleanfalse
default:
Defines the component can be moved on x-axis or not
`html`
#### disabledY
type: Booleanfalse
default:
Defines the component can be moved on y-axis or not
`html`
#### disabledW
type: Booleanfalse
default:
Defines the components width can be modify or not
``html`
#### disabledH
type: Booleanfalse
default:
Defines the components height can be modify or not
``html`
#### parent
type: Booleanfalse
default:
Restrict movement and size within its parent node
`html`
#### handles
type: Array['tl', 'tm', 'tr', 'ml', 'mr', 'bl', 'bm', 'br']
default:
Define the array of handles to restrict the element resizing
- tl : Top lefttm
- : Top middletr
- : Top rightmr
- : Middle rightml
- : Middle leftbl
- : Bottom leftbm
- : Bottom middlebr
- : Bottom right
`html`
#### classNameDraggable
type: Stringdraggable
default:
Used to set the custom class of a draggable-resizable component when draggable is enable.
`html`
#### classNameResizable
type: Stringresizable
default:
Used to set the custom class of a draggable-resizable component when resizable is enable.
`html`
#### classNameDragging
type: Stringdragging
default:
Used to set the custom class of a draggable-resizable component when is dragging.
`html`
#### classNameResizing
type: Stringresizing
default:
Used to set the custom class of a draggable-resizable component when is resizing.
`html`
#### classNameActive
type: Stringactive
default:
Used to set the custom class of a draggable-resizable component when is active.
`html`
#### classNameHandle
type: Stringhandle
default:
Used to set the custom common class of each handle element.
`html`
following handle nodes will be rendered
`html`
...
...
#### activated
payload: -
`html`
#### deactivated
payload: -
`html`
#### drag-start
payload: { x: number, y: number }
`html`
#### dragging
payload: { x: number, y: number }
`html`
#### drag-end
payload: { x: number, y: number }
`html`
#### resize-start
payload: { x: number, y: number, w: number, h: number }
`html`
#### resizing
payload: { x: number, y: number, w: number, h: number }v
`html`
#### resize-end
payload: { x: number, y: number, w: number, h: number }
`html`
You need to import another component to use the "adsorption alignment" feature.
This can be used as follows.
`vue
Test
Another test
`
These props apply to DraggableContainer
#### disabled
type: Booleanfalse
default:
Disable this feature
`html`
Test
Another test
#### adsorbParent
type: Booleantrue
default:
Adsorption near parent component
`html`
Test
Another test
#### adsorbCols
type: Arraynull
default:
Custom guides(column)
`html`
Test
Another test
#### adsorbRows
type: Arraynull
default:
Custom guides(row)
`html`
Test
Another test
#### referenceLineVisible
type: Booleantrue
default:
reference line visible
`html`
Test
Another test
#### referenceLineColor
type: String#f00
default:
reference line color
`html``
Test
Another test