Bug Tracker

Changeset 5386

Show
Ignore:
Timestamp:
05/02/08 20:25:00 (8 months ago)
Author:
paul.bakaus
Message:

ui-draggable: droppables work again, IE works again

Location:
trunk/ui
Files:
2 modified

Legend:

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

    r5384 r5386  
    5656             * - Position generation - 
    5757             * This block generates everything position related - it's the core of draggables. 
    58              */          
    59              
     58             */ 
     59              
     60            this.margins = {                                                                                //Cache the margins 
     61                left: (parseInt(this.element.css("marginLeft"),10) || 0), 
     62                top: (parseInt(this.element.css("marginTop"),10) || 0) 
     63            };       
     64 
    6065            this.cssPosition = this.helper.css("position");                                                 //Store the helper's css position 
    6166            this.offset = this.element.offset();                                                            //The element's absolute position on the page 
    6267            this.offset = {                                                                                 //Substract the margins from the element's absolute offset 
    63                 top: this.offset.top - parseInt(this.element.css("marginTop") || 0,10), 
    64                 left: this.offset.left - parseInt(this.element.css("marginLeft") || 0,10) 
    65             }; 
    66              
     68                top: this.offset.top - this.margins.top, 
     69                left: this.offset.left - this.margins.left 
     70            }; 
     71 
    6772            this.offset.click = {                                                                           //Where the click happened, relative to the element 
    6873                left: e.pageX - this.offset.left, 
    6974                top: e.pageY - this.offset.top 
    7075            }; 
    71              
     76     
    7277            this.offsetParent = this.helper.offsetParent(); var po = this.offsetParent.offset();            //Get the offsetParent and cache its position 
    7378            this.offset.parent = {                                                                          //Store its position plus border 
    74                 top: po.top + parseInt(this.offsetParent.css("borderTopWidth") || 0,10), 
    75                 left: po.left + parseInt(this.offsetParent.css("borderLeftWidth") || 0,10) 
    76             }; 
    77              
     79                top: po.top + (parseInt(this.offsetParent.css("borderTopWidth"),10) || 0), 
     80                left: po.left + (parseInt(this.offsetParent.css("borderLeftWidth"),10) || 0) 
     81            }; 
     82     
    7883            var p = this.element.position();                                                                //This is a relative to absolute position minus the actual position calculation - only used for relative positioned helpers 
    7984            this.offset.relative = this.cssPosition == "relative" ? { 
    80                 top: p.top - parseInt(this.helper.css("top") || 0,10) + this.offsetParent[0].scrollTop, 
    81                 left: p.left - parseInt(this.helper.css("left") || 0,10) + this.offsetParent[0].scrollLeft 
     85                top: p.top - (parseInt(this.helper.css("top"),10) || 0) + this.offsetParent[0].scrollTop, 
     86                left: p.left - (parseInt(this.helper.css("left"),10) || 0) + this.offsetParent[0].scrollLeft 
    8287            } : { top: 0, left: 0 }; 
    83              
     88         
    8489            this.originalPosition = this.generatePosition(e);                                               //Generate the original position 
    8590            this.helperProportions = { width: this.helper.outerWidth(), height: this.helper.outerHeight() };//Cache the helper size 
     
    106111 
    107112                    this.containment = [ 
    108                         co.left + parseInt($(ce).css("borderLeftWidth"),10) - this.offset.relative.left - this.offset.parent.left, 
    109                         co.top + parseInt($(ce).css("borderTopWidth"),10) - this.offset.relative.top - this.offset.parent.top, 
    110                         co.left+Math.max(ce.scrollWidth,ce.offsetWidth) - parseInt($(ce).css("borderLeftWidth"),10) - this.offset.relative.left - this.offset.parent.left - this.helperProportions.width - parseInt(this.element.css("marginLeft") || 0,10) - parseInt(this.element.css("marginRight") || 0,10), 
    111                         co.top+Math.max(ce.scrollHeight,ce.offsetHeight) - parseInt($(ce).css("borderTopWidth"),10) - this.offset.relative.top - this.offset.parent.top - this.helperProportions.height - parseInt(this.element.css("marginTop") || 0,10) - parseInt(this.element.css("marginTop") || 0,10) 
     113                        co.left + (parseInt($(ce).css("borderLeftWidth"),10) || 0) - this.offset.relative.left - this.offset.parent.left, 
     114                        co.top + (parseInt($(ce).css("borderTopWidth"),10) || 0) - this.offset.relative.top - this.offset.parent.top, 
     115                        co.left+Math.max(ce.scrollWidth,ce.offsetWidth) - (parseInt($(ce).css("borderLeftWidth"),10) || 0) - this.offset.relative.left - this.offset.parent.left - this.helperProportions.width - this.margins.left - (parseInt(this.element.css("marginRight"),10) || 0), 
     116                        co.top+Math.max(ce.scrollHeight,ce.offsetHeight) - (parseInt($(ce).css("borderTopWidth"),10) || 0) - this.offset.relative.top - this.offset.parent.top - this.helperProportions.height - this.margins.top - (parseInt(this.element.css("marginBottom"),10) || 0) 
    112117                    ]; 
    113118                } 
     
    123128            return false; 
    124129 
     130        }, 
     131        generateAbsolutePosition: function(pos) { 
     132            return { 
     133                top: ( 
     134                    pos.top                                                                 // the calculated relative position 
     135                    + this.offset.relative.top                                              // Only for relative positioned nodes: Relative offset from element to offset parent 
     136                    + this.offset.parent.top                                                // The offsetParent's offset without borders (offset + border) 
     137                    - (this.cssPosition == "fixed" ? 0 : this.offsetParent[0].scrollTop)    // The offsetParent's scroll position, not if the element is fixed 
     138                    + this.margins.top                                                      //Add the margin (you don't want the margin counting in intersection methods) 
     139                ), 
     140                left: ( 
     141                    pos.left                                                                // the calculated relative position 
     142                    + this.offset.relative.left                                             // Only for relative positioned nodes: Relative offset from element to offset parent 
     143                    + this.offset.parent.left                                               // The offsetParent's offset without borders (offset + border) 
     144                    - (this.cssPosition == "fixed" ? 0 : this.offsetParent[0].scrollLeft)   // The offsetParent's scroll position, not if the element is fixed 
     145                    + this.margins.left                                                     //Add the margin (you don't want the margin counting in intersection methods) 
     146                ) 
     147            }; 
    125148        }, 
    126149        generatePosition: function(e) { 
     
    143166                ) 
    144167            }; 
    145              
     168 
    146169            if(!this.originalPosition) return position;                                     //If we are not dragging yet, we won't check for options 
    147170             
     
    172195            //Compute the helpers position 
    173196            this.position = this.generatePosition(e); 
     197            this.positionAbs = this.generateAbsolutePosition(this.position); 
    174198 
    175199            //Call plugins and callbacks and use the resulting position if something is returned         
     
    183207        }, 
    184208        stop: function(e) { 
    185              
     209         
    186210            //If we are using droppables, inform the manager about the drop 
    187211            if ($.ui.ddmanager && !this.options.dropBehaviour) 
  • trunk/ui/ui.droppable.js

    r5300 r5386  
    194194                break; 
    195195            case 'pointer': 
    196                 return (   l < ((draggable.positionAbs || draggable.position.absolute).left + draggable.clickOffset.left) && ((draggable.positionAbs || draggable.position.absolute).left + draggable.clickOffset.left) < r 
    197                     && t < ((draggable.positionAbs || draggable.position.absolute).top + draggable.clickOffset.top) && ((draggable.positionAbs || draggable.position.absolute).top + draggable.clickOffset.top) < b); 
     196                return (   l < ((draggable.positionAbs || draggable.position.absolute).left + (draggable.clickOffset || draggable.offset.click).left) && ((draggable.positionAbs || draggable.position.absolute).left + (draggable.clickOffset || draggable.offset.click).left) < r 
     197                    && t < ((draggable.positionAbs || draggable.position.absolute).top + (draggable.clickOffset || draggable.offset.click).top) && ((draggable.positionAbs || draggable.position.absolute).top + (draggable.clickOffset || draggable.offset.click).top) < b); 
    198198                break; 
    199199            case 'touch':