qi.jquery draggable containment unusual problem

qi.jquery draggable containment unusual problem


I have an unusual situation while setting the draggable - the problem
is that containment is smaller than the draggable object. So the
draggable is visible through a "window", and the window is the
containment.
If I just set containment to that "window", trying to move the object
results in snapping object to it's lower right corner. Is there some
way to fix that behaviour?
I even tried to understand and edit the jquery-ui source code to add
this functionality, but I don't have enough experience and knowledge
in JavaScript, so it didn't work in Opera 9.2x, but works in Opera
9.5. In Opera 9.2x draggable can be moved only horizontally.
My attempt:
        if(this.containment) {
            /* //unchanged source version
            if(position.left < this.containment[0]) position.left =
this.containment[0];
            if(position.top < this.containment[1]) position.top =
this.containment[1];
            if(position.left > this.containment[2]) position.left =
this.containment[2];
            if(position.top > this.containment[3]) position.top =
this.containment[3];
            */
            // - changed source -
            if ($(o.containment).height() > this.helper.height()) {
                if(position.top < this.containment[1]) position.top =
this.containment[1];
                if(position.top > this.containment[3]) position.top =
this.containment[3];
            } else {
                if(position.top > this.containment[1]) position.top =
this.containment[1];
                if(position.top < this.containment[3]) position.top =
this.containment[3];
            }
            if ($(o.containment).width() > this.helper.width()) {
                if(position.left < this.containment[0]) position.left =
this.containment[0];
                if(position.left > this.containment[2]) position.left =
this.containment[2];
            } else {
                if(position.left > this.containment[0]) position.left =
this.containment[0];
                if(position.left < this.containment[2]) position.left =
this.containment[2];
            }
            // - end of changed source -
        }