Skip to content

Commit

Permalink
fix: Account for margin in drag and drop
Browse files Browse the repository at this point in the history
  • Loading branch information
Jexordexan committed Feb 16, 2021
1 parent 37630b2 commit 0c571bb
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/ContainerMixin.js
Expand Up @@ -329,6 +329,11 @@ export const ContainerMixin = {
intializeOffsets(e, clientRect) {
const { useWindowAsScrollContainer, containerBoundingRect, _window } = this;

this.marginOffset = {
x: this.margin.left + this.margin.right,
y: Math.max(this.margin.top, this.margin.bottom),
};

this._axis = {
x: this.axis.indexOf('x') >= 0,
y: this.axis.indexOf('y') >= 0,
Expand Down Expand Up @@ -389,10 +394,10 @@ export const ContainerMixin = {
this.container.appendChild(this.sortableGhost);
const ghostRect = this.sortableGhost.getBoundingClientRect();
this.boundingClientRect = ghostRect;
this.margin = getElementMargin(this.sortableGhost);
this.width = ghostRect.width;
this.height = ghostRect.height;

this.marginOffset = { x: 0, y: 0 };
this.intializeOffsets(e, helperBoundingRect);
this.offsetEdge = {
top: helperBoundingRect.top + this.initialScroll.top + this.initialWindowScroll.top,
Expand Down

0 comments on commit 0c571bb

Please sign in to comment.