Git Product home page Git Product logo

Comments (18)

David-Desmaisons avatar David-Desmaisons commented on May 18, 2024 12

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.

BENcorry avatar BENcorry commented on May 18, 2024 9

it trigger so much times when i use move props and return false, how can i solve this problem.

from vue.draggable.

dorian-marchal avatar dorian-marchal commented on May 18, 2024 8

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.

David-Desmaisons avatar David-Desmaisons commented on May 18, 2024

I am working on this, I should be abble to provide shortly a hook to cancel drag operation.

from vue.draggable.

pmartelletti avatar pmartelletti commented on May 18, 2024

@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.

David-Desmaisons avatar David-Desmaisons commented on May 18, 2024

@pmartelletti Will this fit your needs?

from vue.draggable.

David-Desmaisons avatar David-Desmaisons commented on May 18, 2024

@pmartelletti , clone prop has been released in version 2.6.0-rc0. The documentation has been updated accordingly.

Cheers & Merry Christmas!

from vue.draggable.

pmartelletti avatar pmartelletti commented on May 18, 2024

@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.

sunilkumarverma avatar sunilkumarverma commented on May 18, 2024

platform

from vue.draggable.

sunilkumarverma avatar sunilkumarverma commented on May 18, 2024

i have to stop drop event when element moving from block1 to block3 directly

from vue.draggable.

David-Desmaisons avatar David-Desmaisons commented on May 18, 2024

@sunilkumarverma , You should use the move props.

from vue.draggable.

heroBack avatar heroBack commented on May 18, 2024

how to start(from ReadME)

from vue.draggable.

towfiles avatar towfiles commented on May 18, 2024

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.

smilingkite avatar smilingkite commented on May 18, 2024

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.

luckyboy07 avatar luckyboy07 commented on May 18, 2024

any workaround on this issue?

from vue.draggable.

FlavioOliveiraNeto avatar FlavioOliveiraNeto commented on May 18, 2024

@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.

AreebaAyub avatar AreebaAyub commented on May 18, 2024

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.

fabioselau077 avatar fabioselau077 commented on May 18, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.