Red Taz
Red Taz

Reputation: 4179

JQuery draggable calculates incorrect helper position

Within draggable elements I have helper 'icons' which I'm using as the visual indicator of the drag. But, when I give the draggable elements padding, jQuery is taking the top left corner as the start and revert position for the helper instead of its real position, see http://jsfiddle.net/G2j76/1/

Is this a bug or am I making a mistake setting this up?

Upvotes: 0

Views: 561

Answers (1)

Niels
Niels

Reputation: 49929

Try adding this:

.ui-draggable-dragging
{
    margin : 11px;  
}

You've got your padding in the draggable element, but the element you see dragging is a child element. If you add 11px margin (1px border + 10px padding), it will be positioned on the right position.

DEMO: http://jsfiddle.net/G2j76/2/

Upvotes: 2

Related Questions