Skip to content

Commit

Permalink
fix: Modify Drag values according to containerPadding
Browse files Browse the repository at this point in the history
  • Loading branch information
hywlss9 committed Oct 30, 2020
1 parent e4e2b8b commit 010719d
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/GridItem.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -469,20 +469,20 @@ export default class GridItem extends React.Component<Props, State> {
const { margin, rowHeight } = this.props;
const bottomBoundary =
offsetParent.clientHeight - calcGridItemWHPx(h, rowHeight, margin[1]);
top = clamp(top, 0, bottomBoundary);
top = clamp(top - this.props.containerPadding[1], 0, bottomBoundary);

const colWidth = calcGridColWidth(positionParams);
const rightBoundary =
containerWidth - calcGridItemWHPx(w, colWidth, margin[0]);
left = clamp(left, 0, rightBoundary);
left = clamp(left - this.props.containerPadding[0], 0, rightBoundary);
}
}

const newPosition: PartialPosition = { top, left };
this.setState({ dragging: newPosition });

// Call callback with this data
const { x, y } = calcXY(positionParams, top, left, w, h);
const { x, y } = calcXY(positionParams, top - this.props.containerPadding[1], left - this.props.containerPadding[0], w, h);
return onDrag.call(this, i, x, y, {
e,
node,
Expand All @@ -507,7 +507,7 @@ export default class GridItem extends React.Component<Props, State> {
const newPosition: PartialPosition = { top, left };
this.setState({ dragging: null });

const { x, y } = calcXY(this.getPositionParams(), top, left, w, h);
const { x, y } = calcXY(this.getPositionParams(), top - this.props.containerPadding[1], left - this.props.containerPadding[0], w, h);

return onDragStop.call(this, i, x, y, {
e,
Expand Down

0 comments on commit 010719d

Please sign in to comment.