Resizable: Store size based on calculated helper size to prevent 1 pixel shifts. Fixes #9547 - Resizable: off-by-one pixel dimensions with helper and grid

(cherry picked from commit 14065dc23b)
This commit is contained in:
Kris Borchers 2013-10-15 21:40:49 -05:00 committed by Scott González
parent 77a31b01f9
commit e29e5b56af
2 changed files with 16 additions and 1 deletions

View File

@ -191,4 +191,19 @@ test("resizable accounts for scroll position correctly (#3815)", function() {
equal( el.css("top"), top, "css('top') stays the same when resized" ); equal( el.css("top"), top, "css('top') stays the same when resized" );
}); });
test( "resizable stores correct size when using helper and grid (#9547)", function() {
expect( 2 );
var handle = ".ui-resizable-se",
target = $( "#resizable1" ).resizable({
handles: "all",
helper: "ui-resizable-helper",
grid: [ 10, 10 ]
});
TestHelpers.resizable.drag( handle, 1, 1 );
equal( target.width(), 100, "compare width" );
equal( target.height(), 100, "compare height" );
});
})(jQuery); })(jQuery);

View File

@ -293,7 +293,7 @@ $.widget("ui.resizable", $.ui.mouse, {
//Store needed variables //Store needed variables
this.offset = this.helper.offset(); this.offset = this.helper.offset();
this.position = { left: curleft, top: curtop }; this.position = { left: curleft, top: curtop };
this.size = this._helper ? { width: el.outerWidth(), height: el.outerHeight() } : { width: el.width(), height: el.height() }; this.size = this._helper ? { width: this.helper.width(), height: this.helper.height() } : { width: el.width(), height: el.height() };
this.originalSize = this._helper ? { width: el.outerWidth(), height: el.outerHeight() } : { width: el.width(), height: el.height() }; this.originalSize = this._helper ? { width: el.outerWidth(), height: el.outerHeight() } : { width: el.width(), height: el.height() };
this.originalPosition = { left: curleft, top: curtop }; this.originalPosition = { left: curleft, top: curtop };
this.sizeDiff = { width: el.outerWidth() - el.width(), height: el.outerHeight() - el.height() }; this.sizeDiff = { width: el.outerWidth() - el.width(), height: el.outerHeight() - el.height() };