Relative position to container

4 posts, 1 answers
  1. Voss
    Voss avatar
    11 posts
    Member since:
    Jul 2014

    Posted 12 Aug 2014 Link to this post

    Is there a way to get the relative position to it's container of a dropped element ?

    thanks.
  2. Iliana Nikolova
    Admin
    Iliana Nikolova avatar
    2595 posts

    Posted 14 Aug 2014 Link to this post

    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!
     
  3. Kendo UI is VS 2017 Ready
  4. Voss
    Voss avatar
    11 posts
    Member since:
    Jul 2014

    Posted 14 Aug 2014 in reply to Iliana Nikolova Link to this post

    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.
  5. Answer
    Iliana Nikolova
    Admin
    Iliana Nikolova avatar
    2595 posts

    Posted 18 Aug 2014 Link to this post

    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!
     
Back to Top
Kendo UI is VS 2017 Ready