Want to move one image close to other image on the basis of CSS margin calculation
<p>Want to move one image close to other image on the basis of CSS margin calculation in Javascript. I am basically a game developer So that is why i used physics vector movement formula this thing works in C++, but not over here. Can any body guide me what wrong i am doing. As one more thing i notice that the margin i specified in CSS is not actually applied to image difference is 8px always there. Function i use setTimeOut to loop through this function until image arrive near to destination.</p>

<pre><code>function moveImage( image1, image2, debugSpanID, debugingOption  ) 
{
    var objImage1 = document.getElementById(image1);
    var objImage2 = document.getElementById(image2);

    objVec = new Vector();

    objVec.setPoint1( objImage1.offsetLeft, objImage1.offsetTop );
    objVec.setPoint2( objImage2.offsetLeft, objImage2.offsetTop );

    objVec.subtract();


    x = objImage1.offsetLeft; 
    y = objImage1.offsetTop;
    objImage1.style.marginLeft = ((objImage1.offsetLeft - (objVec.getUnitVector().getXAxis() *0.0001))) +'px';


    objImage1.style.marginTop = ((objImage1.offsetTop -(objVec.getUnitVector().getYAxis() * 0.0001)))+'px';
}
</code></pre>
