-4

When i drop the draggable div in the drop zone, it is going to the top left corner. Then then one after goes below it.

I need it so if i drop it in the middle of the drop zone, then it will append when i left it. So i am trying to use the positions and setting the css but its not working

here is my js

$('.tab-list img').draggable({
        helper: "clone"
    });

    $('#main').droppable({
        drop:function(event, ui) {
            var item = $(ui.draggable);

            var add;
            if(item.data('itemstate') == 'rectangle'){
                add = '<div class="pi-rectangle"></div>';
            }
            $(add).css('left', ui.position.left);
            $(add).css('top', ui.position.top);
            console.log(ui.position.top);
            console.log(ui.position.left);
            $(add).appendTo(this);
        }
    });
user3613245
  • 79
  • 2
  • 11

1 Answers1

0

i figured it out anyway

$(add).css('left', ui.position.left-80+'px').css('top', ui.position.top-80+'px').appendTo(this);
user3613245
  • 79
  • 2
  • 11