Gathering detailed insights and metrics for vue-draggable-anywhere
Gathering detailed insights and metrics for vue-draggable-anywhere
Gathering detailed insights and metrics for vue-draggable-anywhere
Gathering detailed insights and metrics for vue-draggable-anywhere
npm install vue-draggable-anywhere
Typescript
Module System
Node Version
NPM Version
71.4
Supply Chain
98.3
Quality
75.8
Maintenance
100
Vulnerability
100
License
TypeScript (54.51%)
JavaScript (45.49%)
Love this project? Help keep it running — sponsor us today! 🚀
Total Downloads
1,393
Last Day
1
Last Week
5
Last Month
49
Last Year
448
23 Commits
1 Watchers
1 Branches
1 Contributors
Updated on Feb 06, 2024
Minified
Minified + Gzipped
Latest Version
1.2.0
Package Id
vue-draggable-anywhere@1.2.0
Unpacked Size
22.75 kB
Size
6.52 kB
File Count
4
NPM Version
10.2.4
Node Version
20.11.0
Published on
Feb 06, 2024
Cumulative downloads
Total Downloads
Last Day
-66.7%
1
Compared to previous day
Last Week
-70.6%
5
Compared to previous week
Last Month
96%
49
Compared to previous month
Last Year
-52.6%
448
Compared to previous year
No dependencies detected.
vue-draggable-anywhere
is a Vue.js package supported by Vue3 that enables draggable behavior for HTML elements. It provides an easy-to-use directive to make any element draggable within a specified boundary.
get vue-draggable in npmjs.com
Support for Vue 3:
Cross-Browser Compatibility:
Detailed Documentation:
Community Support:
Examples:
To use this package in your Vue.js project, you need to install it using npm. Run the following command in your terminal:
1npm install vue-draggable-anywhere
To make an element draggable, use the v-draggable directive on the desired HTML element. Below is an example of how to use it:
1<template> 2 <div style="height: 400px; width: 100%;background: cornflowerblue;"> 3 <p>{{ position }}</p> 4 <button 5 v-draggable 6 style="width: 40px; height: 40px; background: red; display:flex; align-items: center;text-align: center; cursor: move; color: white;border-radius: 50%;" 7 > 8 Move 9 </button> 10 </div> 11</template>
1<script setup> 2 import useDraggable from 'vue-draggable-anywhere' 3 const { vDraggable, position } = useDraggable() 4</script>
1<template> 2 <div class="parentClass" style="height: 400px; width: 400px; margin: 20px; background: cornflowerblue;"> 3 <p>{{ position }}</p> 4 <button 5 v-draggable="configuration" 6 style="width: 40px; height: 40px; background: red; display:flex; align-items: center;text-align: center; cursor: move; color: white;border-radius: 50%;" 7 > 8 Move 9 </button> 10 </div> 11</template>
1<script setup> 2 import useDraggable from 'vue-draggable-anywhere' 3 4 const { vDraggable, position } = useDraggable() 5 const configuration = { 6 boundaryElement: '.parentClass', 7 boundary: true, 8 boundaryOffset: { 9 x: -20, 10 y: 30 11 }, 12 onDragging: test, 13 afterDragEnd: test 14 } 15 16 function test(position) { 17 console.log(position) 18 } 19</script>
1<template> 2 <div class="parentClass" style="height: 400px; width: 400px; margin: 20px; background: cornflowerblue;"> 3 <p>{{ position }}</p> 4 <button 5 v-draggable="configuration" 6 style="width: 40px; height: 40px; background: red; display:flex; align-items: center;text-align: center; cursor: move; color: white;border-radius: 50%;" 7 > 8 Move 1 9 </button> 10 <button 11 v-draggable="configuration" 12 style="width: 40px; height: 40px; background: red; display:flex; align-items: center;text-align: center; cursor: move; color: white;border-radius: 50%;" 13 > 14 Move 2 15 </button> 16 </div> 17</template>
1<script setup> 2 import useDraggable from 'vue-draggable-anywhere' 3 4 const { vDraggable, position } = useDraggable() 5 const configuration = { 6 boundaryElement: '.parentClass', 7 boundary: true, 8 boundaryOffset: { 9 x: -20, 10 y: 30 11 }, 12 onDragging: test, 13 afterDragEnd: test 14 } 15 16 function test(position) { 17 console.log(position) 18 } 19</script>
note: If you want you can use separate configuration for every element, if you don't need configuration you can skip.
Mobile Touch Support:
Multi-Element Draggable Support:
Conditional Draggable:
Separate Configurations:
Dynamic Position Tracking:
Event Handling:
Boundary Element:
Scrollable Container Support:
x
0
y
0
draggable
true
false
to disable dragging.boundary
false
true
to define a boundary for the draggable element.boundaryOffset
0
boundaryOffset
not work if boundary
set to falseboundaryOffset: 0 or boundaryOffset: {x: 20, y: -40}
boundaryElement
Type: String
Default: None
Description: CSS selector of the boundary element, that contains the draggable element. For example code follow this section: Example with configuration
scrollableParentElement
Example Code:
1<template> 2 <p>{{ position }}</p> 3 <main class="scrollableParentElement" style="height: 300px; width: 300px; overflow: auto; background-color: springgreen; padding: 16px;"> 4 <div class="boundaryElement" style="height: 500px; width: 100%; background-color: tomato;"> 5 <button v-draggable="configuration" style="width: 50px; height: 50px; background: white;"> 6 Move 7 </button> 8 </div> 9 </main> 10</template>
1<script setup> 2 import useDraggable from 'vue-draggable-anywhere' 3 4 const { vDraggable, position } = useDraggable() 5 const configuration = { 6 boundaryElement: '.boundaryElement', 7 scrollableParentElement: '.scrollableParentElement', 8 boundary: true, 9 boundaryOffset: { 10 x: 10, 11 y: 0 12 } 13 } 14</script>
onDragStart
onDragStart: yourFunction
onDragging
onDragging: yourFunction
afterDragEnd
afterDragEnd: yourFunction
No vulnerabilities found.
No security vulnerabilities found.