Bug Tracker

Changeset 4205

Show
Ignore:
Timestamp:
12/17/07 15:37:26 (1 year ago)
Author:
paul.bakaus
Message:

- containment option works fine again (hopefully)

Location:
trunk/ui/experimental/mouse
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • trunk/ui/experimental/mouse/drag.html

    r4203 r4205  
    3636            height: 400px; 
    3737            border: 10px solid black; 
    38             overflow: scroll; 
    3938            position: absolute; 
    4039            left: 100px; 
     
    6564                }, 
    6665                cursor: 'move', 
    67                 containment: 'parent', 
     66                containment: { top: 10, left: 10, right: 10, bottom: 10 }, 
    6867                //axis: 'x', 
    6968                //grid: [20,20], 
  • trunk/ui/experimental/mouse/ui.draggable.ext.js

    r4203 r4205  
    113113             
    114114            if(c.constructor == Array) { 
    115  
    116  
    117115                if((ui.absolutePosition.left < c[0])) self.position.left = c[0] - (self.offset.left - self.clickOffset.left); 
    118116                if((ui.absolutePosition.top < c[1])) self.position.top = c[1] - (self.offset.top - self.clickOffset.top); 
    119                 //if(ui.draggable.pos[0]+h[0].offsetWidth > c[2]-o.po.left) ui.draggable.pos[0] = c[2]-o.po.left-h[0].offsetWidth; 
    120                 //if(ui.draggable.pos[1]+h[0].offsetHeight > c[3]-o.po.top) ui.draggable.pos[1] = c[3]-o.po.top-h[0].offsetHeight; 
    121  
     117                if(ui.absolutePosition.left - c[2] + self.helperProportions.width >= 0) self.position.left = c[2] - (self.offset.left - self.clickOffset.left) - self.helperProportions.width; 
     118                if(ui.absolutePosition.top - c[3] + self.helperProportions.height >= 0) self.position.top = c[3] - (self.offset.top - self.clickOffset.top) - self.helperProportions.height; 
    122119            } else { 
    123  
    124                 if(c.left && (ui.draggable.pos[0] < c.left)) ui.draggable.pos[0] = c.left; 
    125                 if(c.top && (ui.draggable.pos[1] < c.top)) ui.draggable.pos[1] = c.top; 
    126  
    127                 var p = $(o.pp); 
    128                 if(c.right && ui.draggable.pos[0]+h[0].offsetWidth > p[0].offsetWidth-c.right) ui.draggable.pos[0] = (p[0].offsetWidth-c.right)-h[0].offsetWidth; 
    129                 if(c.bottom && ui.draggable.pos[1]+h[0].offsetHeight > p[0].offsetHeight-c.bottom) ui.draggable.pos[1] = (p[0].offsetHeight-c.bottom)-h[0].offsetHeight; 
    130  
     120                if((ui.position.left < c.left)) self.position.left = c.left; 
     121                if((ui.position.top < c.top)) self.position.top = c.top; 
     122                if(ui.position.left - self.offsetParent.innerWidth() + self.helperProportions.width + c.right + (parseInt(self.offsetParent.css("borderLeftWidth")) || 0) + (parseInt(self.offsetParent.css("borderRightWidth")) || 0) >= 0) self.position.left = self.offsetParent.innerWidth() - self.helperProportions.width - c.right - (parseInt(self.offsetParent.css("borderLeftWidth")) || 0) - (parseInt(self.offsetParent.css("borderRightWidth")) || 0); 
     123                if(ui.position.top - self.offsetParent.innerHeight() + self.helperProportions.height + c.bottom + (parseInt(self.offsetParent.css("borderTopWidth")) || 0) + (parseInt(self.offsetParent.css("borderBottomWidth")) || 0) >= 0) self.position.top = self.offsetParent.innerHeight() - self.helperProportions.height - c.bottom - (parseInt(self.offsetParent.css("borderTopWidth")) || 0) - (parseInt(self.offsetParent.css("borderBottomWidth")) || 0); 
    131124            } 
    132  
    133125 
    134126        } 
  • trunk/ui/experimental/mouse/ui.draggable.js

    r4203 r4205  
    5050            return { 
    5151                helper: this.helper, 
    52                 position: { left: this.position, top: this.position }, 
     52                position: this.position, 
    5353                absolutePosition: this.positionAbs, 
    5454                instance: this, 
     
    8282 
    8383            //Find out the next positioned parent 
    84             var offsetParent = (function(cp) { 
     84            this.offsetParent = (function(cp) { 
    8585                while(cp) { 
    8686                    if(cp.style && /(absolute|relative|fixed)/.test($.css(cp,'position'))) return $(cp); 
     
    9898            //Generate the original position 
    9999            this.originalPosition = { 
    100                 left: (r ? parseInt(this.helper.css('left')) || 0 : elementPosition.left + (offsetParent[0] == document.body ? 0 : offsetParent[0].scrollLeft)), 
    101                 top: (r ? parseInt(this.helper.css('top')) || 0 : elementPosition.top + (offsetParent[0] == document.body ? 0 : offsetParent[0].scrollTop)) 
     100                left: (r ? parseInt(this.helper.css('left')) || 0 : elementPosition.left + (this.offsetParent[0] == document.body ? 0 : this.offsetParent[0].scrollLeft)), 
     101                top: (r ? parseInt(this.helper.css('top')) || 0 : elementPosition.top + (this.offsetParent[0] == document.body ? 0 : this.offsetParent[0].scrollTop)) 
    102102            }; 
    103103