@@ -341,14 +341,19 @@ $.widget("ui.resizable", $.ui.mouse, {
341341 el = this . helper , props = { } ,
342342 smp = this . originalMousePosition ,
343343 a = this . axis ,
344- prevTop = this . position . top ,
345- prevLeft = this . position . left ,
346- prevWidth = this . size . width ,
347- prevHeight = this . size . height ,
348344 dx = ( event . pageX - smp . left ) || 0 ,
349345 dy = ( event . pageY - smp . top ) || 0 ,
350346 trigger = this . _change [ a ] ;
351347
348+ this . prevPosition = {
349+ top : this . position . top ,
350+ left : this . position . left
351+ } ;
352+ this . prevSize = {
353+ width : this . size . width ,
354+ height : this . size . height
355+ } ;
356+
352357 if ( ! trigger ) {
353358 return false ;
354359 }
@@ -369,16 +374,16 @@ $.widget("ui.resizable", $.ui.mouse, {
369374 // plugins callbacks need to be called first
370375 this . _propagate ( "resize" , event ) ;
371376
372- if ( this . position . top !== prevTop ) {
377+ if ( this . position . top !== this . prevPosition . top ) {
373378 props . top = this . position . top + "px" ;
374379 }
375- if ( this . position . left !== prevLeft ) {
380+ if ( this . position . left !== this . prevPosition . left ) {
376381 props . left = this . position . left + "px" ;
377382 }
378- if ( this . size . width !== prevWidth ) {
383+ if ( this . size . width !== this . prevSize . width ) {
379384 props . width = this . size . width + "px" ;
380385 }
381- if ( this . size . height !== prevHeight ) {
386+ if ( this . size . height !== this . prevSize . height ) {
382387 props . height = this . size . height + "px" ;
383388 }
384389 el . css ( props ) ;
@@ -662,7 +667,9 @@ $.widget("ui.resizable", $.ui.mouse, {
662667 position : this . position ,
663668 size : this . size ,
664669 originalSize : this . originalSize ,
665- originalPosition : this . originalPosition
670+ originalPosition : this . originalPosition ,
671+ prevSize : this . prevSize ,
672+ prevPosition : this . prevPosition
666673 } ;
667674 }
668675
@@ -779,7 +786,7 @@ $.ui.plugin.add( "resizable", "containment", {
779786 }
780787 } ,
781788
782- resize : function ( event ) {
789+ resize : function ( event , ui ) {
783790 var woset , hoset , isParent , isOffsetRelative ,
784791 that = $ ( this ) . resizable ( "instance" ) ,
785792 o = that . options ,
@@ -790,7 +797,8 @@ $.ui.plugin.add( "resizable", "containment", {
790797 top : 0 ,
791798 left : 0
792799 } ,
793- ce = that . containerElement ;
800+ ce = that . containerElement ,
801+ continueResize = true ;
794802
795803 if ( ce [ 0 ] !== document && ( / s t a t i c / ) . test ( ce . css ( "position" ) ) ) {
796804 cop = co ;
@@ -800,6 +808,7 @@ $.ui.plugin.add( "resizable", "containment", {
800808 that . size . width = that . size . width + ( that . _helper ? ( that . position . left - co . left ) : ( that . position . left - cop . left ) ) ;
801809 if ( pRatio ) {
802810 that . size . height = that . size . width / that . aspectRatio ;
811+ continueResize = false ;
803812 }
804813 that . position . left = o . helper ? co . left : 0 ;
805814 }
@@ -808,6 +817,7 @@ $.ui.plugin.add( "resizable", "containment", {
808817 that . size . height = that . size . height + ( that . _helper ? ( that . position . top - co . top ) : that . position . top ) ;
809818 if ( pRatio ) {
810819 that . size . width = that . size . height * that . aspectRatio ;
820+ continueResize = false ;
811821 }
812822 that . position . top = that . _helper ? co . top : 0 ;
813823 }
@@ -829,15 +839,24 @@ $.ui.plugin.add( "resizable", "containment", {
829839 that . size . width = that . parentData . width - woset ;
830840 if ( pRatio ) {
831841 that . size . height = that . size . width / that . aspectRatio ;
842+ continueResize = false ;
832843 }
833844 }
834845
835846 if ( hoset + that . size . height >= that . parentData . height ) {
836847 that . size . height = that . parentData . height - hoset ;
837848 if ( pRatio ) {
838849 that . size . width = that . size . height * that . aspectRatio ;
850+ continueResize = false ;
839851 }
840852 }
853+
854+ if ( ! continueResize ) {
855+ that . position . left = ui . prevPosition . left ;
856+ that . position . top = ui . prevPosition . top ;
857+ that . size . width = ui . prevSize . width ;
858+ that . size . height = ui . prevSize . height ;
859+ }
841860 } ,
842861
843862 stop : function ( ) {
0 commit comments