Skip to content
Browse files

Resizable: Trigger resize event only when element is resized. Fixed #…

…5545

- Callbacks ignore the grid.
  • Loading branch information...
1 parent fc6e96b commit 38d5670ad31ed98671151c3fcfbd47cc90a6c9dd @eromba committed Jul 10, 2012
Showing with 81 additions and 2 deletions.
  1. +77 −0 tests/unit/resizable/resizable_events.js
  2. +4 −2 ui/jquery.ui.resizable.js
View
77 tests/unit/resizable/resizable_events.js
@@ -5,4 +5,81 @@
module("resizable: events");
+test("start", function() {
+
+ expect(1);
+
+ var count = 0,
+ handle = '.ui-resizable-se';
+ el = $("#resizable1").resizable({
+ handles: 'all',
+ start: function(event, ui) {
+ count++;
+ }
+ });
+
+ drag(handle, 50, 50);
+
+ equal(count, 1, "start callback should happen exactly once");
+
+});
+
+test("resize", function() {
+
+ expect(1);
+
+ var count = 0,
+ handle = '.ui-resizable-e';
+ el = $("#resizable1").resizable({
+ handles: 'all',
+ resize: function(event, ui) {
+ count++;
+ }
+ });
+
+ drag(handle, 50, 50);
+
+ equal(count, 2, "resize callback should happen exactly once per size adjustment");
+
+});
+
+test("resize (grid)", function() {
+
+ expect(1);
+
+ var count = 0,
+ handle = '.ui-resizable-se';
+ el = $("#resizable1").resizable({
+ handles: 'all',
+ grid: 50,
+ resize: function(event, ui) {
+ count++;
+ },
+ });
+
+ drag(handle, 50, 50);
+
+ equal(count, 1, "resize callback should happen exactly once per grid-aligned size adjustment");
+
+});
+
+test("stop", function() {
+
+ expect(1);
+
+ var count = 0,
+ handle = '.ui-resizable-e';
+ el = $("#resizable1").resizable({
+ handles: 'all',
+ stop: function(event, ui) {
+ count++;
+ }
+ });
+
+ drag(handle, 50, 50);
+
+ equal(count, 1, "stop callback should happen exactly once");
+
+});
+
})(jQuery);
View
6 ui/jquery.ui.resizable.js
@@ -317,8 +317,10 @@ $.widget("ui.resizable", $.ui.mouse, {
if (!this._helper && this._proportionallyResizeElements.length)
this._proportionallyResize();
- // calling the user callback at the end
- this._trigger('resize', event, this.ui());
+ // Call the user callback if the element was resized
+ if ( ! $.isEmptyObject(props) ) {
+ this._trigger('resize', event, this.ui());
+ }
return false;
},

0 comments on commit 38d5670

Please sign in to comment.
Something went wrong with that request. Please try again.