]> source.dussan.org Git - jquery-ui.git/commitdiff
Resizable: Fixed sign error on offset calculation. Fixes #9307 - Resizable: Erratic...
authorChristian Klammer <christian314159@gmail.com>
Thu, 16 May 2013 11:26:13 +0000 (21:26 +1000)
committerMike Sherov <mike.sherov@gmail.com>
Wed, 29 May 2013 12:18:58 +0000 (08:18 -0400)
tests/unit/resizable/resizable_events.js
ui/jquery.ui.resizable.js

index ac222ec106d87c79102e5c8d1a6557698fb82baa..18e25bfdf18062f0ee7055010a0c5770014ba88f 100644 (file)
@@ -170,4 +170,51 @@ test("stop", function() {
 
 });
 
+test( "resize (containment) works with parent with negative offset", function() {
+
+       expect( 1 );
+
+       var widthBefore, widthAfter,
+               handle = ".ui-resizable-e",
+               target = $( "#resizable1" ),
+               absoluteContainer = target.wrap( "<div />" ).parent(),
+               fixedContainer = absoluteContainer.wrap( "<div />" ).parent(),
+               increaseWidthBy = 50;
+
+       // position fixed container in window top left
+       fixedContainer.css({
+               width: 400,
+               height: 100,
+               position: "fixed",
+               top: 0,
+               left: 0
+       });
+
+       // position absolute container within fixed on slightly outside window
+       absoluteContainer.css({
+               width: 400,
+               height: 100,
+               position: "absolute",
+               top: 0,
+               left: -50
+       });
+
+       // set up resizable to be contained within absolute container
+       target.resizable({
+               handles: "all",
+               containment: "parent"
+       }).css({
+               width: 300
+       });
+
+       widthBefore = target.width();
+
+       TestHelpers.resizable.drag( handle, increaseWidthBy, 0 );
+
+       widthAfter = target.width();
+
+       equal( widthAfter, ( widthBefore + increaseWidthBy ), "resizable width should be increased by the value dragged" );
+
+});
+
 })(jQuery);
index c84323e8ad37382a81668c1ba4549290828717f5..aab93b57fd7da63fbe7554697d6d3bed23e5098a 100644 (file)
@@ -797,8 +797,8 @@ $.ui.plugin.add("resizable", "containment", {
                isParent = that.containerElement.get(0) === that.element.parent().get(0);
                isOffsetRelative = /relative|absolute/.test(that.containerElement.css("position"));
 
-               if(isParent && isOffsetRelative) {
-                       woset -= that.parentData.left;
+               if ( isParent && isOffsetRelative ) {
+                       woset -= Math.abs( that.parentData.left );
                }
 
                if (woset + that.size.width >= that.parentData.width) {