I had to do something similar to what it sounds like you're doing, which is create a constraint based on the draggable area being bigger than the container (like a draggable map). I edited jquery-ui.js to do the following, similar to the containment, but called constraint.
Set it in your code like you would containment:
$("#draggable").draggable({
axis: 'y',
constraint: 'parent'
});
line 731:
constraint: false,
line 849:
//Set a constraint if given in the options
if(o.constraint)
this._setConstraint();
line 1071:
_setConstraint: function() {
var o = this.options;
if(o.constraint == 'parent') o.constraint = this.helper[0].parentNode;
if(o.constraint == 'document' || o.constraint == 'window') this.constraint = [
0 - this.offset.relative.left - this.offset.parent.left,
0 - this.offset.relative.top - this.offset.parent.top,
$(o.constraint == 'document' ? document : window).width() - this.helperProportions.width - this.margins.left,
($(o.constraint == 'document' ? document : window).height() || document.body.parentNode.scrollHeight) - this.helperProportions.height - this.margins.top
];
if(!(/^(document|window|parent)$/).test(o.constraint) && o.constraint.constructor != Array) {
var ce = $(o.constraint)[0]; if(!ce) return;
var co = $(o.constraint).offset();
var over = ($(ce).css("overflow") != 'hidden');
this.constraint = [
co.left + (parseInt($(ce).css("borderLeftWidth"),10) || 0) + (parseInt($(ce).css("paddingLeft"),10) || 0) - this.margins.left,
co.top + (parseInt($(ce).css("borderTopWidth"),10) || 0) + (parseInt($(ce).css("paddingTop"),10) || 0) - this.margins.top,
co.left+(over ? Math.max(ce.scrollWidth,ce.offsetWidth) : ce.offsetWidth) - (parseInt($(ce).css("borderLeftWidth"),10) || 0) - (parseInt($(ce).css("paddingRight"),10) || 0) - this.helperProportions.width - this.margins.left,
co.top+(over ? Math.max(ce.scrollHeight,ce.offsetHeight) : ce.offsetHeight) - (parseInt($(ce).css("borderTopWidth"),10) || 0) - (parseInt($(ce).css("paddingBottom"),10) || 0) - this.helperProportions.height - this.margins.top
];
} else if(o.constraint.constructor == Array) {
this.constraint = o.constraint;
}
},
line 1142, in the _generatePosition function:
if(this.constraint) {
if(event.pageX - this.offset.click.left > this.constraint[0]) pageX = this.constraint[0] + this.offset.click.left;
if(event.pageY - this.offset.click.top > this.constraint[1]) pageY = this.constraint[1] + this.offset.click.top;
if(event.pageX - this.offset.click.left < this.constraint[2]) pageX = this.constraint[2] + this.offset.click.left;
if(event.pageY - this.offset.click.top < this.constraint[3]) pageY = this.constraint[3] + this.offset.click.top;
}