From f9b579aac954bbede72f8124af2525450e3a810d Mon Sep 17 00:00:00 2001 From: Christopher Heath Date: Wed, 5 Aug 2015 16:43:39 -0500 Subject: [PATCH] Fix issue with the dragging of widgets pushing off to the right funny with larger margin sizes. The margin was not being taken into account for the new position properly. This meant that if you were in column 10 and the margin was set to 20px the previous calculation was off by 200 pixels. New calculation for the placeholder position and the drag stop position takes the margin for the sizes multiplied by the column we want to determine how far to offset left. --- src/jquery.gridster.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/jquery.gridster.js b/src/jquery.gridster.js index 8ea745607..cc3f3df48 100755 --- a/src/jquery.gridster.js +++ b/src/jquery.gridster.js @@ -1490,9 +1490,13 @@ if (this.$player === null) { return false; } + + var margin_sides = this.options.widget_margins[0]; + + var placeholder_column = this.$preview_holder.attr('data-col'); var abs_offset = { - left: ui.position.left + this.baseX, + left: ui.position.left + this.baseX - (margin_sides * placeholder_column), top: ui.position.top + this.baseY }; @@ -1540,8 +1544,12 @@ fn.on_stop_drag = function (event, ui) { this.$helper.add(this.$player).add(this.$wrapper) .removeClass('dragging'); + + var margin_sides = this.options.widget_margins[0]; - ui.position.left = ui.position.left + this.baseX; + var placeholder_column = this.$preview_holder.attr('data-col'); + + ui.position.left = ui.position.left + this.baseX - (margin_sides * placeholder_column); ui.position.top = ui.position.top + this.baseY; this.colliders_data = this.collision_api.get_closest_colliders( ui.position);