Skip to content

Commit 4ad61c9

Browse files
committed
Changed element size calculations.
1 parent fe9c9f8 commit 4ad61c9

File tree

1 file changed

+20
-15
lines changed

1 file changed

+20
-15
lines changed

ui/widgets/resizable.js

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -711,31 +711,36 @@ $.widget( "ui.resizable", $.ui.mouse, {
711711
}
712712

713713
// Check if CSS inline styles are set and use those (usually from previous resizes)
714-
var elWidth = ce.style.width === "" ? "" : parseFloat( ce.style.width );
715-
var elHeight = ce.style.height === "" ? "" : parseFloat( ce.style.height );
714+
var elWidth = parseFloat( ce.style.width );
715+
var elHeight = parseFloat( ce.style.height );
716716

717-
if ( elWidth === "" ) {
718-
elWidth = this._getElementSizeWithoutOverflow( element, "width" );
719-
}
720-
if ( elHeight === "" ) {
721-
elHeight = this._getElementSizeWithoutOverflow( element, "height" );
722-
}
717+
var paddingBorder = this._getPaddingPlusBorderDimensions( element );
718+
elWidth = isNaN( elWidth ) ?
719+
this._getElementTheoreticalSize( element, paddingBorder, "width" ) :
720+
elWidth;
721+
elHeight = isNaN( elHeight ) ?
722+
this._getElementTheoreticalSize( element, paddingBorder, "height" ) :
723+
elHeight;
723724

724725
return {
725726
height: elHeight,
726727
width: elWidth
727728
};
728729
},
729730

730-
_getElementSizeWithoutOverflow: function( element, sizeProperty ) {
731-
var overflowProperty = sizeProperty === "width" ? "overflow-y" : "overflow-x";
731+
_getElementTheoreticalSize: function( element, extraSize, dimension ) {
732+
733+
// offsetWidth/offsetHeight is a rounded sum of content, padding, scroll gutter, and border
734+
var size = Math.max( 0, Math.ceil(
735+
element.get( 0 )[ "offset" + dimension[ 0 ].toUpperCase() + dimension.slice( 1 ) ] -
736+
extraSize[ dimension ] -
737+
0.5
732738

733-
var origOverflow = element.css( overflowProperty );
734-
element.css( overflowProperty, "hidden" );
735-
var elSize = parseFloat( element.css( sizeProperty ) );
736-
element.css( overflowProperty, origOverflow );
739+
// If offsetWidth/offsetHeight is unknown, then we can't determine theoretical size.
740+
// Use an explicit zero to avoid NaN (gh-3964)
741+
) ) || 0;
737742

738-
return elSize;
743+
return size;
739744
},
740745

741746
_proportionallyResize: function() {

0 commit comments

Comments
 (0)