Skip to content

Commit 9926cef

Browse files
committed
fix(gridster): fire positionschanged when widget orig position changes
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).
1 parent 7640971 commit 9926cef

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/jquery.gridster.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -841,13 +841,15 @@
841841
fn.register_widget = function($el) {
842842
var isDOM = $el instanceof jQuery;
843843
var wgd = isDOM ? this.dom_to_coords($el) : $el;
844+
var posChanged = false;
844845
isDOM || ($el = wgd.el);
845846

846847
var empty_upper_row = this.can_go_widget_up(wgd);
847848
if (empty_upper_row) {
848849
wgd.row = empty_upper_row;
849850
$el.attr('data-row', empty_upper_row);
850851
this.$el.trigger('gridster:positionchanged', [wgd]);
852+
posChanged = true;
851853
}
852854

853855
if (this.options.avoid_overlapped_widgets &&
@@ -861,6 +863,7 @@
861863
'data-sizex': wgd.size_x,
862864
'data-sizey': wgd.size_y
863865
});
866+
posChanged = true;
864867
}
865868

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

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

875-
return !! empty_upper_row;
878+
return posChanged;
876879
};
877880

878881

0 commit comments

Comments
 (0)