Javascript drag from mouse position?
<p>I have a script which allows a user to drag a div around the screen on iOS, and as it is now, when you start to drag a div, it makes the dragable point the center. Is it possible to make this point wherever the user touches?</p>

<p>The code looks like this:</p>

<pre><code>    xPos = drag.offsetWidth / 2;
    yPos = drag.offsetHeight / 2;
    drag.addEventListener("touchmove", function() {
        event.preventDefault();
        $(this).css({
            "left" : event.targetTouches[0].pageX - xPos + "px", 
            "top" : event.targetTouches[0].pageY - yPos + "px",
            "z-index" : "1000"
        });
        $("div").not(this).css("z-index", "1"); 
        $("div[id]").each(function() {
            var id = $(this).attr("id");
            localStorage.setItem(id + "-z","1");
        });     
    });
</code></pre>

<p>Is there anyway I can make it so that the offset is however far away the user's finger is away from the box's edge?</p>

<hr>

<p>I thought the following might work but it doesn't seem to, all it does is cause it to jitter:</p>

<pre><code>$(this).css({
"left" : event.targetTouches[0].pageX - parseInt($(this).css("left"), 10) +  "px", 
"top" : event.targetTouches[0].pageY  - parseInt($(this).css("top"), 10) +  "px",
});
</code></pre>
