Moving an element retrieving values from dragged one
Hi there, I'm moving an element using the draggable UI from jquery.
With the drag event I get the left value of the element dinamically while I do the dragging. Afterwords, I use animate to give this values to the left css value of another element so it moves as much as the dragged one.
This works fine, but I would like this element to move at a different speed than the dragged...
Sounds easy but:
Let's say I want the second element to move 1'5 pixels for every pixel the dragged one moves, this seems to be as simple as multiplying:
function onDrag()
{
var moving = #('dragged').offset().left*1.5;
$('#moveme').animate({'left' : (moving) + 'px'}, 0);
}
The problem is:
When you do this, the $('#moveme') element moves exactly at the perfect spped, but it start's it's movement in the first offset().left value og $('#dragged') so there is a jump. I would like it to move at the same speed but from it's own offset().left starting position.
I can't find the way to express this in a Math's function without causing a mess. Any help?