Ticket #3328: containment_in_overflow_hidden.diff

File containment_in_overflow_hidden.diff, 2.2 KB (added by c_t, 2 years ago)

Make containment-restriction work for containers with overflow:hidden

  • ui.core.js

     
    283283                        .unbind('selectstart.ui'); 
    284284        }, 
    285285        hasScroll: function(e, a) { 
     286                // We can assume, that the element has no scrollbars if it's overflow is set to hidden 
     287                if ($(e).css('overflow') == 'hidden') { return false; } 
     288 
    286289                var scroll = (a && a == 'left') ? 'scrollLeft' : 'scrollTop', 
    287290                        has = false; 
    288291                 
  • ui.draggable.js

     
    118118                        if(!(/^(document|window|parent)$/).test(o.containment)) { 
    119119                                var ce = $(o.containment)[0]; 
    120120                                var co = $(o.containment).offset(); 
     121                                var over = ($(ce).css("overflow") != 'hidden'); 
    121122                                 
    122123                                this.containment = [ 
    123124                                        co.left + (parseInt($(ce).css("borderLeftWidth"),10) || 0) - this.offset.relative.left - this.offset.parent.left, 
    124125                                        co.top + (parseInt($(ce).css("borderTopWidth"),10) || 0) - this.offset.relative.top - this.offset.parent.top, 
    125                                         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), 
    126                                         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) 
     126                                        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.element.css("marginRight"),10) || 0), 
     127                                        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.element.css("marginBottom"),10) || 0) 
    127128                                ]; 
    128129                        } 
    129130                }