Gathering detailed insights and metrics for vue-draggable-resizable
Gathering detailed insights and metrics for vue-draggable-resizable
Gathering detailed insights and metrics for vue-draggable-resizable
Gathering detailed insights and metrics for vue-draggable-resizable
npm install vue-draggable-resizable
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
3,335 Stars
167 Commits
559 Forks
45 Watching
7 Branches
17 Contributors
Updated on 27 Nov 2024
Minified
Minified + Gzipped
Vue (53.7%)
JavaScript (44.05%)
CSS (1.87%)
HTML (0.38%)
Cumulative downloads
Total Downloads
Last day
0.2%
6,980
Compared to previous day
Last week
-1.9%
37,037
Compared to previous week
Last month
23.8%
162,562
Compared to previous month
Last year
11.6%
1,458,140
Compared to previous year
Vue Component for draggable and resizable elements.
If you are looking for the version 1 of the component, it is available on the v1 branch.
For examples of the component go to the live playground
Alternatively you can run the playground on your own computer:
npm install
npm run story:dev
1$ npm install --save vue-draggable-resizable
Register the component globally
1// main.js 2import { createApp } from 'vue' 3import VueDraggableResizable from 'vue-draggable-resizable' 4import App from './App.vue' 5 6createApp(App) 7 .component("vue-draggable-resizable", VueDraggableResizable) 8 .mount('#app')
You may now use the component in your markup
1// App.vue 2<template> 3 <div style="height: 500px; width: 500px; border: 1px solid red; position: relative;"> 4 <vue-draggable-resizable :w="100" :h="100" :parent="true"> 5 <p>Hello! I'm a flexible component. You can drag me around and you can resize me.</p> 6 </vue-draggable-resizable> 7 </div> 8</template>
The component itself does not include any CSS. You'll need to include it separately in your App.vue
:
1<style> 2@import "vue-draggable-resizable/style.css"; 3</style>
Type: String
Required: false
Default: vdr
Used to set the custom class
of a draggable-resizable component.
1<vue-draggable-resizable class-name="my-class">
Type: String
Required: false
Default: draggable
Used to set the custom class
of a draggable-resizable component when draggable
is enable.
1<vue-draggable-resizable class-name-draggable="my-draggable-class">
Type: String
Required: false
Default: resizable
Used to set the custom class
of a draggable-resizable component when resizable
is enable.
1<vue-draggable-resizable class-name-resizable="my-resizable-class">
Type: String
Required: false
Default: dragging
Used to set the custom class
of a draggable-resizable component when is dragging.
1<vue-draggable-resizable class-name-dragging="my-dragging-class">
Type: String
Required: false
Default: resizing
Used to set the custom class
of a draggable-resizable component when is resizing.
1<vue-draggable-resizable class-name-resizing="my-resizing-class">
Type: String
Required: false
Default: active
Used to set the custom class
of a draggable-resizable component when is active.
1<vue-draggable-resizable class-name-active="my-active-class">
Type: String
Required: false
Default: handle
Used to set the custom common class
of each handle element. This way you can style each handle individually using the selector <your class>-<handle code>
, where handle code
identifies one of the handles provided by the handle
prop.
So for example, this component:
1<vue-draggable-resizable class-name-handle="my-handle-class"></vue-draggable-resizable>
renders the following:
1<div ...> 2 <div class="my-handle-class my-handle-class-tl"></div> 3 <div class="my-handle-class my-handle-class-tm"></div> 4 <div class="my-handle-class my-handle-class-tr"></div> 5 [...] 6</div>
Type: Number|Array
Required: false
Default: 1
The scale
prop controls the scale property when the CSS 3 scale transformation is applied to one of the parent elements. If not provided the default value is 1.
1<vue-draggable-resizable :scale="0.5"> 2 3<vue-draggable-resizable :scale="[0.5, 0.4]">
Type: Boolean
Required: false
Default: true
By default, the component adds the style declaration 'user-select:none'
to itself to prevent text selection during drag. You can disable this behaviour by setting this prop to false
.
1<vue-draggable-resizable :disable-user-select="false">
Type: Boolean
Required: false
Default: false
By default, the browser's native drag and drop funcionality (usually used for images and some other elements) is disabled, as it may conflict with the one provided by the component. If you need, for whatever reason, to have this functionality back you can set this prop to true
.
1<vue-draggable-resizable :enable-native-drag="true">
Type: Boolean
Required: false
Default: false
Determines if the component should be active or not. The prop reacts to changes and also can be used with the sync
modifier to keep the state in sync with the parent. You can use along with the preventDeactivation
prop in order to fully control the active behavior from outside the component.
1<vue-draggable-resizable :active="true">
Type: Boolean
Required: false
Default: false
Determines if the component should be deactivated when the user clicks/taps outside it.
1<vue-draggable-resizable :prevent-deactivation="true">
Type: Boolean
Required: false
Default: true
Defines it the component should be draggable or not.
1<vue-draggable-resizable :draggable="false">
Type: Boolean
Required: false
Default: true
Defines it the component should be resizable or not.
1<vue-draggable-resizable :resizable="false">
Type: Number|String
Required: false
Default: 200
Define the initial width of the element. It also supports auto
, but when you start resizing the value will fallback to a number.
1<vue-draggable-resizable :w="200">
Type: Number|String
Required: false
Default: 200
Define the initial height of the element. It also supports auto
, but when you start resizing the value will fallback to a number.
1<vue-draggable-resizable :h="200">
Type: Number
Required: false
Default: 50
Define the minimal width of the element.
1<vue-draggable-resizable :min-width="50">
Type: Number
Required: false
Default: 50
Define the minimal height of the element.
1<vue-draggable-resizable :min-height="50">
Type: Number
Required: false
Default: null
Define the maximum width of the element.
1<vue-draggable-resizable :max-width="400">
Type: Number
Required: false
Default: null
Define the maximum height of the element.
1<vue-draggable-resizable :max-height="50">
Type: Number
Required: false
Default: 0
Define the initial x position of the element.
1<vue-draggable-resizable :x="0">
Type: Number
Required: false
Default: 0
Define the initial y position of the element.
1<vue-draggable-resizable :y="0">
Type: Number|String
Required: false
Default: auto
Define the z-index of the element.
1<vue-draggable-resizable :z="999">
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 left1<vue-draggable-resizable :handles="['tm','bm','ml','mr']">
Type: String
Required: false
Default: both
Define the axis on which the element is draggable. Available values are x
, y
or both
.
1<vue-draggable-resizable axis="x">
Type: Array
Required: false
Default: [1,1]
Define the grid on which the element is snapped.
1<vue-draggable-resizable :grid="[1,1]">
Type: Boolean
Required: false
Default: false
Restricts the movement and the dimensions of the component to the parent.
1<vue-draggable-resizable :parent="true">
Type: String
Required: false
Defines the selector that should be used to drag the component.
1<vue-draggable-resizable drag-handle=".drag">
Type: String
Required: false
Defines a selector that should be used to prevent drag initialization.
1<vue-draggable-resizable drag-cancel=".drag">
Type: Boolean
Required: false
Default: false
The lockAspectRatio
property is used to lock aspect ratio. This property doesn't play well with grid
, so make sure to use only one at a time.
1<vue-draggable-resizable :lock-aspect-ratio="true">
Type: Function
Required: false
Default: null
Called when dragging starts (element is clicked or touched). If false
is returned by any handler, the action will cancel. You can use this function to prevent bubbling of events.
1<vue-draggable-resizable :onDragStart="onDragStartCallback">
1function onDragStartCallback(ev){ 2 ... 3 // return false; — for cancel 4}
Type: Function
Required: false
Default: null
Called before the element is dragged. The function receives the next values of x
and y
. If false
is returned by any handler, the action will cancel.
1<vue-draggable-resizable :onDrag="onDragCallback">
1function onDragStartCallback(x, y){ 2 ... 3 // return false; — for cancel 4}
Type: Function
Required: false
Default: null
Called when resizing starts (handle is clicked or touched). If false
is returned by any handler, the action will cancel.
1<vue-draggable-resizable :onResizeStart="onResizeStartCallback">
1 2function onResizeStartCallback(handle, ev){ 3 ... 4 // return false; — for cancel 5}
Type: Function
Required: false
Default: null
Called before the element is resized. The function receives the handle and the next values of x
, y
, width
and height
. If false
is returned by any handler, the action will cancel.
1<vue-draggable-resizable :onResize="onResizeCallback">
1
2function onResizeStartCallback(handle, x, y, width, height){
3 ...
4 // return false; — for cancel
5}
Parameters: -
Called whenever the component gets clicked, in order to show handles.
1<vue-draggable-resizable @activated="onActivated">
Parameters: -
Called whenever the user clicks anywhere outside the component, in order to deactivate it.
1<vue-draggable-resizable @deactivated="onDeactivated">
Parameters:
left
the X position of the elementtop
the Y position of the elementwidth
the width of the elementheight
the height of the elementCalled whenever the component gets resized.
1<vue-draggable-resizable @resizing="onResizing">
Parameters:
left
the X position of the elementtop
the Y position of the elementwidth
the width of the elementheight
the height of the elementCalled whenever the component stops getting resized.
1<vue-draggable-resizable @resizestop="onResizestop">
Parameters:
left
the X position of the elementtop
the Y position of the elementCalled whenever the component gets dragged.
1<vue-draggable-resizable @dragging="onDragging">
Parameters:
left
the X position of the elementtop
the Y position of the elementCalled whenever the component stops getting dragged.
1<vue-draggable-resizable @dragstop="onDragstop">
You can style the component using appropriate class names passed as props to the component. Moreover you can replace the default styles for the handles, provided in the source file vue-draggable-resizable.css
, but you should take care to define position and size for them. The default classes for handles are handle
and handle-tl
, handle-br
and so on.
The component also provides named slots for each handle, so you can use your markup inside each one.
Thanks to @kirillmurashov for his work on vue-drag-resize component.
If you discover any security related issues, please email maurizio.bonani@gmail.com instead of using the issue tracker.
Any contribution to the code or any part of the documentation and any idea and/or suggestion are very welcome.
1# serve with hot reload at localhost:8080 2npm run dev 3 4# distribution build 5npm run build 6 7# build the histoire docs 8npm run story:build 9 10# run tests 11npm run test 12 13# run histoire at localhost:6006 14npm run story:dev
The MIT License (MIT). Please see License File for more information.
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
packaging workflow detected
Details
Reason
dependency not pinned by hash detected -- score normalized to 3
Details
Reason
Found 4/19 approved changesets -- score normalized to 2
Reason
8 existing vulnerabilities detected
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2024-11-18
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More