Changeset 1095

Show
Ignore:
Timestamp:
12/11/08 03:18:28 (8 months ago)
Author:
paul.bakaus
Message:

sortable: fixed containment issue (with 'parent', height was miscalculated due to wrong append order)

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/ui/ui.sortable.js

    r1034 r1095  
    135135                this.domPosition = { prev: this.currentItem.prev()[0], parent: this.currentItem.parent()[0] }; 
    136136 
     137                //If the helper is not the original, hide the original so it's not playing any role during the drag, won't cause anything bad this way 
     138                if(this.helper[0] != this.currentItem[0]) { 
     139                        this.currentItem.hide(); 
     140                } 
     141 
     142                //Create the placeholder 
     143                this._createPlaceholder(); 
     144                 
    137145                //Set a containment if given in the options 
    138146                if(o.containment) 
    139147                        this._setContainment(); 
    140  
    141                 //If the helper is not the original, hide the original so it's not playing any role during the drag, won't cause anything bad this way 
    142                 if(this.helper[0] != this.currentItem[0]) { 
    143                         this.currentItem.hide(); 
    144                 } 
    145  
    146                 //Create the placeholder 
    147                 this._createPlaceholder(); 
    148148 
    149149                //Call plugins and callbacks 
     
    703703                        0 - this.offset.relative.left - this.offset.parent.left, 
    704704                        0 - this.offset.relative.top - this.offset.parent.top, 
    705                         $(o.containment == 'document' ? document : window).width() - this.offset.relative.left - this.offset.parent.left - this.helperProportions.width - this.margins.left - (parseInt(this.currentItem.css("marginRight"),10) || 0), 
    706                         ($(o.containment == 'document' ? document : window).height() || document.body.parentNode.scrollHeight) - this.offset.relative.top - this.offset.parent.top - this.helperProportions.height - this.margins.top - (parseInt(this.currentItem.css("marginBottom"),10) || 0) 
     705                        $(o.containment == 'document' ? document : window).width() - this.offset.relative.left - this.offset.parent.left - this.margins.left - (parseInt(this.currentItem.css("marginRight"),10) || 0), 
     706                        ($(o.containment == 'document' ? document : window).height() || document.body.parentNode.scrollHeight) - this.offset.relative.top - this.offset.parent.top - this.margins.top - (parseInt(this.currentItem.css("marginBottom"),10) || 0) 
    707707                ]; 
    708708 
     
    715715                                co.left + (parseInt($(ce).css("borderLeftWidth"),10) || 0) - this.offset.relative.left - this.offset.parent.left, 
    716716                                co.top + (parseInt($(ce).css("borderTopWidth"),10) || 0) - this.offset.relative.top - this.offset.parent.top, 
    717                                 co.left+(over ? Math.max(ce.scrollWidth,ce.offsetWidth) : ce.offsetWidth) - (parseInt($(ce).css("borderLeftWidth"),10) || 0) - this.offset.relative.left - this.offset.parent.left - this.helperProportions.width - this.margins.left - (parseInt(this.currentItem.css("marginRight"),10) || 0), 
    718                                 co.top+(over ? Math.max(ce.scrollHeight,ce.offsetHeight) : ce.offsetHeight) - (parseInt($(ce).css("borderTopWidth"),10) || 0) - this.offset.relative.top - this.offset.parent.top - this.helperProportions.height - this.margins.top - (parseInt(this.currentItem.css("marginBottom"),10) || 0) 
     717                                co.left + (over ? Math.max(ce.scrollWidth,ce.offsetWidth) : ce.offsetWidth) - (parseInt($(ce).css("borderLeftWidth"),10) || 0) - this.offset.relative.left - this.offset.parent.left - this.margins.left - (parseInt(this.currentItem.css("marginRight"),10) || 0), 
     718                                co.top + (over ? Math.max(ce.scrollHeight,ce.offsetHeight) : ce.offsetHeight) - (parseInt($(ce).css("borderTopWidth"),10) || 0) - this.offset.relative.top - this.offset.parent.top - this.margins.top - (parseInt(this.currentItem.css("marginBottom"),10) || 0) 
    719719                        ]; 
    720720                } 
     
    775775                        if(position.left < this.containment[0]) position.left = this.containment[0]; 
    776776                        if(position.top < this.containment[1]) position.top = this.containment[1]; 
    777                         if(position.left > this.containment[2]) position.left = this.containment[2]; 
    778                         if(position.top > this.containment[3]) position.top = this.containment[3]; 
     777                        if(position.left + this.helperProportions.width > this.containment[2]) position.left = this.containment[2] - this.helperProportions.width; 
     778                        if(position.top + this.helperProportions.height > this.containment[3]) position.top = this.containment[3] - this.helperProportions.height; 
    779779                } 
    780780