Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
draggable-vue-directive
Advanced tools
A simple directive to handle drag and drop of any Vue component
Vue directive (Vue.js 2.0) for handling element drag & drop.
npm install draggable-vue-directive --save
<div v-draggable>
classic draggable
</div>
.vue file:
import { Draggable } from 'draggable-vue-directive'
...
export default {
directives: {
Draggable,
},
...
<div v-draggable="draggableValue">
<div :ref="handleId">
<img src="../assets/move.svg" alt="move">
</div>
drag and drop using handler
</div>
.vue file:
import { Draggable } from 'draggable-vue-directive'
...
export default {
directives: {
Draggable,
},
data() {
return {
handleId: "handle-id",
draggableValue: { };
}
},
mounted() {
this.draggableValue.handle = this.$refs[this.handleId];
}
...
Type: HtmlElement | Vue
Required: false
There are two ways to use the draggable-vue-directive as showen in the demo above.
The simple use is just to put the directive on any Vue component or Html element and boom! the element is draggable.
The second option is to use handler. if you choose to use handler, the component itself will be draggable only using the handler.
Type: Function
Required: false
In some cases it is useful to know the coordinates of the element when it's been dragged.
Passing a callback to draggableValue
will achieve this goal and every time the element is being dragged the callback
will be executed with the current position as param.
import { Draggable } from 'draggable-vue-directive'
...
export default {
directives: {
Draggable,
},
data() {
return {
handleId: "handle-id",
draggableValue: { };
}
},
mounted() {
this.draggableValue.handle = this.$refs[this.handleId];
this.draggableValue.onPositionChange = this.onPosChanged;
},
methods: {
onPosChanged: function(pos) {
console.log("left corner", pos.x);
console.log("top corner", pos.y);
}
}
...
Type: Boolean
Required: false
Type: Boolean
Required: false
FAQs
A simple directive to handle drag and drop of any Vue component
The npm package draggable-vue-directive receives a total of 8,312 weekly downloads. As such, draggable-vue-directive popularity was classified as popular.
We found that draggable-vue-directive demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.