This is a migrated thread and some comments may be shown as answers.

Prevent Draggable snap back

6 Answers 376 Views
Drag and Drop
This is a migrated thread and some comments may be shown as answers.
Marlon
Top achievements
Rank 1
Marlon asked on 06 Nov 2013, 02:38 PM
I want to create a sticky notes-type widget where a user can drag a div around the screen. I thought kendoDraggable could do that. But when I release the div, it just snaps back to where it was. Can I prevent that functionality where the element stays where I dragged it?

6 Answers, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 08 Nov 2013, 12:05 PM
Hello Marlon,

You should also use a kendoDropTarget or kendoDropTargetArea and handle drop event. 

Regards,
Daniel
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
OMER
Top achievements
Rank 1
answered on 23 Apr 2014, 10:40 AM
Could you please give an example on how it is done?
I tried doing that, but it doesn't happen.
I've tried to set e.preventDefault() in the "dragend" event in the draggable item.
I've added animation effects to the "e.target" in the "drop" event in the dropTarget element.
It doesn't seem to work.
Here's my plunkr: 
http://plnkr.co/edit/APUkPgnGyxN9tr9gVd9Z?p=preview
I get the wanted animation when I have a debug point, but get no animation otherwise.
0
Daniel
Telerik team
answered on 25 Apr 2014, 09:09 AM
Hello,

Basically, you should use the drop event to move the element or absolutely position it to the new position. I created a small example that demonstrates both cases.

Regards,
Daniel
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
OMER
Top achievements
Rank 1
answered on 29 May 2014, 04:33 PM
Thanks. I'm half way where I want.
What I'm interested in is this:
1) Start dragging.
2) On drop, do an effect on the hint (fade and zoom, to be exact :)).
When I try to do it, the hint just disappears.
Here's the plunkr:
http://plnkr.co/edit/APUkPgnGyxN9tr9gVd9Z?p=preview
How can I make the hint disappear with an effect?
0
OMER
Top achievements
Rank 1
answered on 29 May 2014, 05:49 PM
Ok,
As it usually happens after posting in a forum, I have found a solution.
Here's a working solution:
http://plnkr.co/edit/APUkPgnGyxN9tr9gVd9Z?p=preview
The idea was to clone the "hint" element, append it to the body, do the effect with the cloned element, and then remove it from the DOM.
Even though I have found a solution that works, I would like to know if Telerik's staff has a better one (more efficient or API-ish, maybe).
0
Daniel
Telerik team
answered on 31 May 2014, 11:25 AM
Hello,

The approach seems correct. Currently, built-in animations for the hint on drop are not available.

Regards,
Daniel
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
Drag and Drop
Asked by
Marlon
Top achievements
Rank 1
Answers by
Daniel
Telerik team
OMER
Top achievements
Rank 1
Share this question
or