jQuery: The Write Less, Do More JavaScript Library

Changeset 3824

Show
Ignore:
Timestamp:
11/14/07 20:20:00 (9 months ago)
Author:
brandon.aaron
Message:

Dimensions: use clientWidth/Height and offsetWidth/Height in inner/outerWidth/Height methods if element is visible.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/plugins/dimensions/jquery.dimensions.js

    r3581 r3824  
    2727            borr = name == 'Height' ? 'Bottom' : 'Right'; // bottom or right 
    2828         
    29         return num( this, name.toLowerCase() ) + num(this, 'padding' + torl) + num(this, 'padding' + borr); 
     29        return this.is(':visible') ? this[0]['client' + name] : num( this, name.toLowerCase() ) + num(this, 'padding' + torl) + num(this, 'padding' + borr); 
    3030    }; 
    3131     
     
    3939        options = $.extend({ margin: false }, options || {}); 
    4040         
    41         return num( this, name.toLowerCase() ) 
    42                 + num(this, 'border' + torl + 'Width') + num(this, 'border' + borr + 'Width') 
    43                 + num(this, 'padding' + torl) + num(this, 'padding' + borr) 
    44                 + (options.margin ? (num(this, 'margin' + torl) + num(this, 'margin' + borr)) : 0); 
     41        var val = this.is(':visible') ?  
     42                this[0]['offset' + name] :  
     43                num( this, name.toLowerCase() ) 
     44                    + num(this, 'border' + torl + 'Width') + num(this, 'border' + borr + 'Width') 
     45                    + num(this, 'padding' + torl) + num(this, 'padding' + borr); 
     46         
     47        return val + (options.margin ? (num(this, 'margin' + torl) + num(this, 'margin' + borr)) : 0); 
    4548    }; 
    4649});