Draggable

by Mark

HTML

<div id="draggable">
</div>

CSS

#draggable {
    position: relative;
    width: 100px;
    height: 100px;
    background-color: whitesmoke;
    border: 2px solid silver;
}

JavaScript

$(function() {
    $("#draggable").draggable({
        helper: function(){
            // Create an invisible div as the helper. It will move and
            // follow the cursor as usual.
            return $('<div></div>').css('opacity',0);
        },
        drag: function(event, ui){
            // During dragging, animate the original object to
            // follow the invisible helper with custom easing.
            var p = ui.helper.position();
            $(this).stop().animate({
                top: p.top,
                left: p.left
            },0,'easeOutQuad');  // Delay = 0
        }
    });
});