Skip to content

Commit aa499ae

Browse files
author
Ilango Rajagopal
committed
Get width and height when sending drag data to event handlers instead of caching them in drag start handler
1 parent 7c28735 commit aa499ae

File tree

4 files changed

+20
-8
lines changed

4 files changed

+20
-8
lines changed

dist/index.es.js

+4-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.es.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-alignment-guides",
3-
"version": "0.7.16",
3+
"version": "0.7.17",
44
"description": "React Alignment Guides is a guides system for draggable elements in an enclosed space",
55
"keywords": [
66
"drag",

src/Box.js

+14-2
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,13 @@ class Box extends Component {
6868
left: e.clientX - deltaX,
6969
top: e.clientY - deltaY
7070
};
71-
const data = { x: currentPosition.left, y: currentPosition.top, width: startingPosition.width, height: startingPosition.height, node: target };
71+
const data = {
72+
x: currentPosition.left,
73+
y: currentPosition.top,
74+
width: target.offsetWidth,
75+
height: target.offsetHeight,
76+
node: target
77+
};
7278
this.setState({
7379
left: currentPosition.left,
7480
top: currentPosition.top
@@ -84,7 +90,13 @@ class Box extends Component {
8490
left: e.clientX - deltaX,
8591
top: e.clientY - deltaY
8692
};
87-
const data = { x: endPosition.left, y: endPosition.top, width: startingPosition.width, height: startingPosition.height, node: target };
93+
const data = {
94+
x: endPosition.left,
95+
y: endPosition.top,
96+
width: target.offsetWidth,
97+
height: target.offsetHeight,
98+
node: target
99+
};
88100
this.props.onDragEnd && this.props.onDragEnd(e, data);
89101
document.removeEventListener('mousemove', onDrag);
90102
document.removeEventListener('mouseup', onDragEnd);

0 commit comments

Comments
 (0)