views:

20

answers:

1

I'm using jQuery UI's draggable() to make some elements on my page draggable. I've got a handler and a containment set for the elements, but I'd like the draggable element itself to be able to hang out of the containment. I only want the handle to stay inside the container.

Like below, pretend the * is the handle.

+-------------------+
|Containment        |
|                *----------+
|                |Draggable |
|                +----------+
+-------------------+

Is there a sneaky way to do this without having to calculate a new containment myself?

A: 

My solution so far:

function start (e, ui)
{
    var draggable = ui.helper.data('draggable');
    draggable.helperProportions = { height: 10, width: 10 };
    ui.helper.data('draggable', draggable);
    ui.helper.data('draggable')._setContainment();
}

Makes me sad that I'm mucking around in draggable's internals, but it works.

John