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

Relative position to container

3 Answers 105 Views
Drag and Drop
This is a migrated thread and some comments may be shown as answers.
Voss
Top achievements
Rank 1
Voss asked on 12 Aug 2014, 12:17 PM
Is there a way to get the relative position to it's container of a dropped element ?

thanks.

3 Answers, 1 is accepted

Sort by
0
Iliana Dyankova
Telerik team
answered on 14 Aug 2014, 08:08 AM
Hi Voss,

I am not quite sure what your current implementation is - is it possible to provide a simple dojo example which demonstrates it? This way I would be able to advice you further and provide concrete commendations. Thank you in advance for your cooperation.

Regards,
Iliana Nikolova
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Voss
Top achievements
Rank 1
answered on 14 Aug 2014, 12:40 PM
I can, but I think I just didn't explain the questions properly.

I have a square (container) 400x400 centered on the page.
I have a little square in the container that is draggable. 
When I drag then drop the little square inside the container I would like to know it's X/Y coordinates relative to the container and not the entire page.

I guess one way is to calculate the offset from the square, but wanted to check to see if there was a property that would give me this information on DROP.

thanks.
0
Accepted
Iliana Dyankova
Telerik team
answered on 18 Aug 2014, 11:00 AM
Hi Voss,

Thank you for the details. For this requirement I would suggest to attach a handler to the drop event and use the jQuery offset method. As an example:
$("#dropContainer").kendoDropTarget({
  //....
  drop: function(e) {
     //....
     console.log(e.draggable.hint.offset());
  }
});

Regards,
Iliana Nikolova
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
Voss
Top achievements
Rank 1
Answers by
Iliana Dyankova
Telerik team
Voss
Top achievements
Rank 1
Share this question
or