Skip to content

Commit

Permalink
Get width and height when sending drag data to event handlers instead…
Browse files Browse the repository at this point in the history
… of caching them in drag start handler
  • Loading branch information
Ilango Rajagopal committed Jul 26, 2019
1 parent 7c28735 commit aa499ae
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 8 deletions.
8 changes: 4 additions & 4 deletions dist/index.es.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.es.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-alignment-guides",
"version": "0.7.16",
"version": "0.7.17",
"description": "React Alignment Guides is a guides system for draggable elements in an enclosed space",
"keywords": [
"drag",
Expand Down
16 changes: 14 additions & 2 deletions src/Box.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,13 @@ class Box extends Component {
left: e.clientX - deltaX,
top: e.clientY - deltaY
};
const data = { x: currentPosition.left, y: currentPosition.top, width: startingPosition.width, height: startingPosition.height, node: target };
const data = {
x: currentPosition.left,
y: currentPosition.top,
width: target.offsetWidth,
height: target.offsetHeight,
node: target
};
this.setState({
left: currentPosition.left,
top: currentPosition.top
Expand All @@ -84,7 +90,13 @@ class Box extends Component {
left: e.clientX - deltaX,
top: e.clientY - deltaY
};
const data = { x: endPosition.left, y: endPosition.top, width: startingPosition.width, height: startingPosition.height, node: target };
const data = {
x: endPosition.left,
y: endPosition.top,
width: target.offsetWidth,
height: target.offsetHeight,
node: target
};
this.props.onDragEnd && this.props.onDragEnd(e, data);
document.removeEventListener('mousemove', onDrag);
document.removeEventListener('mouseup', onDragEnd);
Expand Down

0 comments on commit aa499ae

Please sign in to comment.