Skip to content

Commit

Permalink
fix(gridster): fire positionschanged when widget orig position changes
Browse files Browse the repository at this point in the history
Until now `gridster:positionschanged` was being fired only if the widget
was moved up, but we also need to know if position is different when
`avoid_overlapped_widgets` is set to true (by default).
  • Loading branch information
vieron committed Jul 25, 2014
1 parent 7640971 commit 9926cef
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/jquery.gridster.js
Original file line number Diff line number Diff line change
Expand Up @@ -841,13 +841,15 @@
fn.register_widget = function($el) {
var isDOM = $el instanceof jQuery;
var wgd = isDOM ? this.dom_to_coords($el) : $el;
var posChanged = false;
isDOM || ($el = wgd.el);

var empty_upper_row = this.can_go_widget_up(wgd);
if (empty_upper_row) {
wgd.row = empty_upper_row;
$el.attr('data-row', empty_upper_row);
this.$el.trigger('gridster:positionchanged', [wgd]);
posChanged = true;
}

if (this.options.avoid_overlapped_widgets &&
Expand All @@ -861,6 +863,7 @@
'data-sizex': wgd.size_x,
'data-sizey': wgd.size_y
});
posChanged = true;
}

// attach Coord object to player data-coord attribute
Expand All @@ -872,7 +875,7 @@

this.options.resize.enabled && this.add_resize_handle($el);

return !! empty_upper_row;
return posChanged;
};


Expand Down

0 comments on commit 9926cef

Please sign in to comment.