@@ -80,9 +80,13 @@ $.widget( "ui.resizable", $.ui.mouse, {
80
80
81
81
_hasScroll : function ( el , a ) {
82
82
83
- if ( $ ( el ) . css ( "overflow" ) === "hidden" ) {
83
+ var overflow = $ ( el ) . css ( "overflow" ) ;
84
+ if ( overflow === "hidden" ) {
84
85
return false ;
85
86
}
87
+ if ( overflow === "scroll" ) {
88
+ return true ;
89
+ }
86
90
87
91
var scroll = ( a && a === "left" ) ? "scrollLeft" : "scrollTop" ,
88
92
has = false ;
@@ -381,15 +385,26 @@ $.widget( "ui.resizable", $.ui.mouse, {
381
385
this . offset = this . helper . offset ( ) ;
382
386
this . position = { left : curleft , top : curtop } ;
383
387
388
+ var calculatedSize = undefined ;
389
+ if ( ! this . _helper ) {
390
+ calculatedSize = this . _calculateAdjustedElementDimensions ( el ) ;
391
+ }
392
+
384
393
this . size = this . _helper ? {
385
394
width : this . helper . width ( ) ,
386
395
height : this . helper . height ( )
387
- } : this . _calculateAdjustedElementDimensions ( el ) ;
396
+ } : {
397
+ width : calculatedSize . width ,
398
+ height : calculatedSize . height
399
+ } ;
388
400
389
401
this . originalSize = this . _helper ? {
390
402
width : el . outerWidth ( ) ,
391
403
height : el . outerHeight ( )
392
- } : this . _calculateAdjustedElementDimensions ( el ) ;
404
+ } : {
405
+ width : calculatedSize . width ,
406
+ height : calculatedSize . height
407
+ } ;
393
408
394
409
this . sizeDiff = {
395
410
width : el . outerWidth ( ) - el . width ( ) ,
@@ -685,20 +700,44 @@ $.widget( "ui.resizable", $.ui.mouse, {
685
700
} ,
686
701
687
702
_calculateAdjustedElementDimensions : function ( element ) {
688
- if ( ! ( / c o n t e n t - b o x / ) . test ( element . css ( "box-sizing" ) ) ) {
689
- return {
690
- height : parseFloat ( element . css ( "height" ) ) ,
691
- width : parseFloat ( element . css ( "width" ) )
692
- } ;
703
+ var ce = element . get ( 0 ) ;
704
+
705
+ if ( element . css ( "box-sizing" ) !== "content-box" ||
706
+ ( ! this . _hasScroll ( ce ) && ! this . _hasScroll ( ce , "left" ) ) ) {
707
+ return {
708
+ height : parseFloat ( element . css ( "height" ) ) ,
709
+ width : parseFloat ( element . css ( "width" ) )
710
+ } ;
711
+ }
712
+
713
+ // 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 ) ;
716
+
717
+ if ( elWidth === "" ) {
718
+ elWidth = this . _getElementSizeWithoutOverflow ( element , "width" ) ;
719
+ }
720
+ if ( elHeight === "" ) {
721
+ elHeight = this . _getElementSizeWithoutOverflow ( element , "height" ) ;
693
722
}
694
723
695
- var outerDimensions = this . _getPaddingPlusBorderDimensions ( element ) ;
696
724
return {
697
- height : element [ 0 ] . getBoundingClientRect ( ) . height - outerDimensions . height ,
698
- width : element [ 0 ] . getBoundingClientRect ( ) . width - outerDimensions . width
725
+ height : elHeight ,
726
+ width : elWidth
699
727
} ;
700
728
} ,
701
729
730
+ _getElementSizeWithoutOverflow : function ( element , sizeProperty ) {
731
+ var overflowProperty = sizeProperty === "width" ? "overflow-y" : "overflow-x" ;
732
+
733
+ var origOverflow = element . css ( overflowProperty ) ;
734
+ element . css ( overflowProperty , "hidden" ) ;
735
+ var elSize = parseFloat ( element . css ( sizeProperty ) ) ;
736
+ element . css ( overflowProperty , origOverflow ) ;
737
+
738
+ return elSize ;
739
+ } ,
740
+
702
741
_proportionallyResize : function ( ) {
703
742
704
743
if ( ! this . _proportionallyResizeElements . length ) {
0 commit comments