Comments (18)
Here is the proposal:
move event will be removed and will be replaced by a move props:
move
Type: Function
Required: false
Default: null
If not null this function will be called in a similar way as Sortable onMove callback.
Returning false will cancel the drag operation.
function onMoveCallback(evt, originalEvent){
...
// return false; — for cancel
}
evt object has same property as Sortable onMove event, plus two addicional properties:
move
event object addicional properties:
- draggedContext:
- index: dragged element index
- element: dragged element underlying view model element
- relatedContext: context linked to current drag position
- index: target index
- element: target view model element
- list: taget list
- component: target VueComponent
Ex:
See Cancel.html for full example.
HTML:
<draggable element="ul" :list="list" :move="checkMove">
...
</draggable>
Javascript:
var vm = new Vue({
...
methods:{
checkMove: function(evt) {
if (evt.draggedContext.element.name=='apple'){
return false
}
if (evt.relatedContext.element && evt.relatedContext.element.name=='strawberry'){
return false
}
if (evt.relatedContext.list.length==2){
return false
}
return true;
},
from vue.draggable.
it trigger so much times when i use move props and return false, how can i solve this problem.
from vue.draggable.
If I understand this correctly, the move
prop doesn't solve the original use case as the drag should be canceled based on the result of an HTTP request (that only fires when the element is dropped, I assume).
An after-move
prop that would revert the change when it returns false
would be nice.
from vue.draggable.
I am working on this, I should be abble to provide shortly a hook to cancel drag operation.
from vue.draggable.
@David-Desmaisons awesome - I thought I was doing something wrong here! Can you let me know when this is ready, please? As would be very helpful for my app. Cheers & happy holidays!
from vue.draggable.
@pmartelletti Will this fit your needs?
from vue.draggable.
@pmartelletti , clone prop has been released in version 2.6.0-rc0. The documentation has been updated accordingly.
Cheers & Merry Christmas!
from vue.draggable.
@David-Desmaisons this is awesome. Will try it on monday, but that's what I was looking for! Thank you very much and merry Christmas to you too! 😄
from vue.draggable.
from vue.draggable.
i have to stop drop event when element moving from block1 to block3 directly
from vue.draggable.
@sunilkumarverma , You should use the move props.
from vue.draggable.
how to start(from ReadME)
from vue.draggable.
is it possible to cancel the dropping of the element if need be?.... i noticed onMove is fired even before you drop the element
from vue.draggable.
I also wonder how to cancel a drag - in my case because the element is let go, but not in a droppable place.
from vue.draggable.
any workaround on this issue?
from vue.draggable.
@David-Desmaisons I want to cancel a drag according to the type of my destination element (I need a data inside of the destination element). I've tried to find the destination element using :move="onMove", but I can't find it, I only find the dragged element.
How can I do this?
Thanks,
from vue.draggable.
i want to cancel drag on drop, but @EnD function doesnot provide reverting an item and :move prop is being called many times, How can i do that ? urgent answer is required
from vue.draggable.
i want to cancel drag on drop, but @EnD function doesnot provide reverting an item and :move prop is being called many times, How can i do that ? urgent answer is required
find fix?
from vue.draggable.
Related Issues (20)
- Get info for card and columns changed
- 拖动到窗口下边缘的时候怎么触发滚动?
- Has anyone found a solution for Max depth nesting with vue-draggable? If there is any parameter for setting the maximum depth in the nested solution?
- 判断被拖拽元素是否在目标区域内并阻止拖拽
- TypeError: Cannot read properties of undefined (reading 'class')
- Draggable preventing scroll behavior HOT 1
- [feature request] typing for `change` event
- Has this project stopped updating and maintaining
- New draggable under maintenance HOT 1
- Incorrect display of the sheet after dragend HOT 2
- npm i -S vuedraggable 直接报错
- VueDraggable only @choose @unchoose events only getting triggered in vue2.7.15 version
- Please set the `latest` npm tag to v4
- Not working with Socket.io
- How to disable draggable in vue draggable HOT 1
- How to import nested-draggable component ? Vue2
- Triggering drag and drop programmatically
- Missing required prop: "itemKey"
- how to lock vuedraggable for specific array nested level
- Nested Draggable Input with v-model automatically blurs
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vue.draggable.