Skip to content

Commit e29e5b5

Browse files
kborchersscottgonzalez
authored andcommitted
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 14065dc)
1 parent 77a31b0 commit e29e5b5

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

tests/unit/resizable/resizable_core.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,4 +191,19 @@ test("resizable accounts for scroll position correctly (#3815)", function() {
191191
equal( el.css("top"), top, "css('top') stays the same when resized" );
192192
});
193193

194+
test( "resizable stores correct size when using helper and grid (#9547)", function() {
195+
expect( 2 );
196+
197+
var handle = ".ui-resizable-se",
198+
target = $( "#resizable1" ).resizable({
199+
handles: "all",
200+
helper: "ui-resizable-helper",
201+
grid: [ 10, 10 ]
202+
});
203+
204+
TestHelpers.resizable.drag( handle, 1, 1 );
205+
equal( target.width(), 100, "compare width" );
206+
equal( target.height(), 100, "compare height" );
207+
});
208+
194209
})(jQuery);

ui/jquery.ui.resizable.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ $.widget("ui.resizable", $.ui.mouse, {
293293
//Store needed variables
294294
this.offset = this.helper.offset();
295295
this.position = { left: curleft, top: curtop };
296-
this.size = this._helper ? { width: el.outerWidth(), height: el.outerHeight() } : { width: el.width(), height: el.height() };
296+
this.size = this._helper ? { width: this.helper.width(), height: this.helper.height() } : { width: el.width(), height: el.height() };
297297
this.originalSize = this._helper ? { width: el.outerWidth(), height: el.outerHeight() } : { width: el.width(), height: el.height() };
298298
this.originalPosition = { left: curleft, top: curtop };
299299
this.sizeDiff = { width: el.outerWidth() - el.width(), height: el.outerHeight() - el.height() };

0 commit comments

Comments
 (0)