You found a bug! We've classified it as EXTJSIV-9324 . We encourage you to continue the discussion and to find an acceptable workaround while we work on a permanent fix.
  1. #1
    Ext JS Premium Member
    Join Date
    May 2009
    Posts
    67
    Vote Rating
    0
    UGA_Zimma is on a distinguished road

      0  

    Default [Ext 4.x] Using the constrainTo Property with a Region is broken in ComponentDragger

    [Ext 4.x] Using the constrainTo Property with a Region is broken in ComponentDragger


    Hey All,

    When I am using a Region defined constrainTo property the Region constantly is adjusted and shrinking. I found the fix in the calculateConstrainRegion function of ComponentDragger. The me.initialConstainTo is being set equal to c and then c is adjusted which changes initialConstainTo. then everytime you drag the element it adjusts the constrainTo Region even more. To fix this we need a copy of the initial Reagion not the pointer to the config that will keep getting adjusted, i.e. - me.initialConstainTo.copy(). (or something of the sorts)

    Thanks,

    UGA_Zimma

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    St. Louis, MO
    Posts
    33,714
    Vote Rating
    438
    mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of

      0  

    Default


    Thanks for the report! I have opened a bug in our bug tracker.

  3. #3
    Ext JS Premium Member
    Join Date
    May 2009
    Posts
    67
    Vote Rating
    0
    UGA_Zimma is on a distinguished road

      0  

    Default


    Thanks!

    Here is the override for anyone interested:

    Code:
    Ext.override(Ext.util.ComponentDragger, {
    
        calculateConstrainRegion : 
    function() {
    
            
    var me = this, comp = me.comp, c = me.initialConstrainTo, delegateRegion, elRegion, dragEl = me.proxy ? me.proxy.el : comp.el, shadowSize = (!me.constrainDelegate && dragEl.shadow && !dragEl.shadowDisabled) ? dragEl.shadow.getShadowSize() : 0;
    
    
            
    // The configured constrainTo might be a Region or an element
    
            
    if(!( c instanceof Ext.util.Region)) {
    
                c = Ext.fly(c).getViewRegion();
    
            } 
    else {
                c = me.initialConstrainTo.copy();
    
            }
    
    
            
    // Reduce the constrain region to allow for shadow
    
            
    if(shadowSize) {
    
                c.adjust(shadowSize[0], -shadowSize[1], -shadowSize[2], shadowSize[3]);
    
            }
    
    
            
    // If they only want to constrain the *delegate* to within the constrain region,
    
            
    // adjust the region to be larger based on the insets of the delegate from the outer
    
            
    // edges of the Component.
    
            
    if(!me.constrainDelegate) {
    
                delegateRegion = Ext.fly(me.dragTarget).getRegion();
    
                elRegion = dragEl.getRegion();
    
    
                c.adjust(delegateRegion.top - elRegion.top, delegateRegion.right - elRegion.right, delegateRegion.bottom - elRegion.bottom, delegateRegion.left - elRegion.left);
    
            }
    
            
    return c;
    
        }
    
    });