Vue-drag-resize
Vue Component for resize and drag elements.
Features
- A lightweight, no-dependency
- Use draggable, resizable or both
- Define sticks for resizing
- Save aspect ratio for resizable components
- Restrict size and movement to parent element
- Restrict drag to vertical or horizontal axis
Install and basic usage
Register the component:
Use the component:
Props
isActive
Type: Boolean
Required: false
Default: false
Determines whether the component should be active.
isDraggable
Type: Boolean
Required: false
Default: true
Determines whether the component should draggable.
isResizable
Type: Boolean
Required: false
Default: true
Determines whether the component should resize.
parentLimitation
Type: Boolean
Required: false
Default: false
Limits the scope of the component's change to its parent size.
aspectRatio
Type: Boolean
Required: false
Default: false
Determines whether the component should retain its proportions.
w
Type: Number
Required: false
Default: 200
Define the initial width of the component.
h
Type: Number
Required: false
Default: 200
Define the initial height of the component.
minw
Type: Number
Required: false
Default: 50
Define the minimal width of the component.
minh
Type: Number
Required: false
Default: 50
Define the minimal height of the component.
x
Type: Number
Required: false
Default: 0
Define the initial x position of the component.
y
Type: Number
Required: false
Default: 0
Define the initial y position of the component.
z
Type: Number|String
Required: false
Default: auto
Define the zIndex of the component.
sticks
Type: Array
Required: false
Default: ['tl', 'tm', 'tr', 'mr', 'br', 'bm', 'bl', 'ml']
Define the array of handles to restrict the element resizing:
tl
- Top lefttm
- Top middletr
- Top rightmr
- Middle rightbr
- Bottom rightbm
- Bottom middlebl
- Bottom leftml
- Middle left
axis
Type: String
Required: false
Default: both
Define the axis on which the element is draggable. Available values are x
, y
, both
or none
.
Events
activated
Required: false
Parameters: -
Called whenever the component gets clicked, in order to show handles.
deactivated
Required: false
Parameters: -
Called whenever the user clicks anywhere outside the component, in order to deactivate it.
resizing
Required: false
Parameters: object
Called whenever the component gets resized.
resizestop
Required: false
Parameters: object
Called whenever the component stops getting resized.
dragging
Required: false
Parameters: object
Called whenever the component gets dragged.
dragstop
Required: false
Parameters: object
Called whenever the component stops getting dragged.
Contributing
Any contribution to the code or any part of the documentation and any idea and/or suggestion are very welcome.