2

Take a look at this fiddle.

When I drag the element a second time its start position is wrong. It is caused by absolute position, this is necessary. Anyone know how to do this? Here is js code

$('.item').draggable({
    drag: function(evt,ui) {
        var zoom = $('.zoom').css('zoom');
        ui.position.top = Math.round(ui.position.top / zoom);
        ui.position.left = Math.round(ui.position.left / zoom);
    }
});
Liam
  • 27,717
  • 28
  • 128
  • 190
  • 1
    In that example, why is `position: absolute` necessary? It ran fine for me without. –  May 30 '13 at 14:53
  • The fiddle doesn't work at all for me (Firefox). In Chrome it works fine when the element is not absolutely positioned. – Pointy May 30 '13 at 14:55
  • @Pointy - Good point, `zoom` isn't supported style in Firefox. See [this answer](http://stackoverflow.com/questions/10278783/what-does-zoom-do-in-css/10278906#10278906) –  May 30 '13 at 14:58
  • @JoshuaM in my file parrent div have relative position and draggable elements are added dynamicly in top 0 and left 0 position. – Paweł Skawicki May 30 '13 at 15:05
  • Then you'll need to post your live code and not a snippet so people can see how it actually needs to work in realtime; with this snippet you've posted it only shows that it works without the `position: absolute` –  May 30 '13 at 15:27

0 Answers0