I want to be able to drag a divider up and down to resize the divs above and below the divider on a fixed page height. These divs could be in a table, although they need not
In case anyone is interested in the future, I got it to work nicely with this:
$('.rsh').draggable({
axis: 'y',
containment: 'parent',
helper: 'clone',
drag: function (event, ui) {
var height = ui.offset.top - 85;
$(this).prev().height(height);
}
});
This is the fiddle.
The use of clone
is the key. The draggable elements (.rsh
) are relative, so if you don't use a clone the element moves twice as far as the mouse because it is also affected by the change in the height of the previous div
.
Note: The - 85
is just a quirk of the page layout making allowance for the header and so forth.