Ticket #2071: css.diff
| File css.diff, 1.6 kB (added by brandon, 7 months ago) |
|---|
-
src/core.js
766 766 767 767 // A method for quickly swapping in/out CSS properties to get correct calculations 768 768 swap: function( elem, options, callback ) { 769 var old = {}; 769 770 // Remember the old values, and insert the new ones 770 771 for ( var name in options ) { 771 elem.style[ "old" +name ] = elem.style[ name ];772 old[ name ] = elem.style[ name ]; 772 773 elem.style[ name ] = options[ name ]; 773 774 } 774 775 … … 776 777 777 778 // Revert the old values 778 779 for ( var name in options ) 779 elem.style[ name ] = elem.style[ "old" +name ];780 elem.style[ name ] = old[ name ]; 780 781 }, 781 782 782 783 css: function( elem, name, force ) { 783 784 if ( name == "width" || name == "height" ) { 784 var width, height, props = { position: "absolute", visibility: "hidden", display:"block" };785 var val, props = { position: "absolute", visibility: "hidden", display:"block" }, which = name == "width" ? [ "Left", "Right" ] : [ "Top", "Bottom" ]; 785 786 786 787 function getWH() { 787 width = elem.clientWidth; 788 height = elem.clientHeight; 788 val = name == "width" ? elem.offsetWidth : elem.offsetHeight; 789 jQuery.each( which, function() { 790 val = val - parseInt(jQuery.curCSS( elem, "padding" + this, true )) || 0; 791 val = val - parseInt(jQuery.curCSS( elem, "border" + this + "Width", true )) || 0; 792 }); 789 793 } 790 794 791 795 if ( jQuery(elem).is(":visible") ) 792 796 getWH(); 793 797 else 794 798 jQuery.swap( elem, props, getWH ); 795 796 return name == "width" ? width : height;799 800 return val; 797 801 } 798 802 799 803 return jQuery.curCSS( elem, name, force );