Skip to content

Commit 2372672

Browse files
committed
Fixing merge conflicts
2 parents 34f5ee3 + d3f9eac commit 2372672

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

lib/draggable.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -356,8 +356,8 @@ module.exports = React.createClass({
356356
// Initiate dragging
357357
this.setState({
358358
dragging: true,
359-
offsetX: dragPoint.clientX,
360-
offsetY: dragPoint.clientY,
359+
offsetX: parseInt(dragPoint.clientX, 10),
360+
offsetY: parseInt(dragPoint.clientY, 10),
361361
startX: parseInt(node.style.left, 10) || 0,
362362
startY: parseInt(node.style.top, 10) || 0
363363
});
@@ -398,12 +398,15 @@ module.exports = React.createClass({
398398

399399
// Snap to grid if prop has been provided
400400
if (Array.isArray(this.props.grid)) {
401-
clientX = Math.abs(clientX - this.state.clientX) >= this.props.grid[0]
402-
? clientX
401+
var directionX = clientX < parseInt(this.state.clientX, 10) ? -1 : 1;
402+
var directionY = clientY < parseInt(this.state.clientY, 10) ? -1 : 1;
403+
404+
clientX = Math.abs(clientX - parseInt(this.state.clientX, 10)) >= this.props.grid[0]
405+
? (parseInt(this.state.clientX, 10) + (this.props.grid[0] * directionX))
403406
: this.state.clientX;
404407

405-
clientY = Math.abs(clientY - this.state.clientY) >= this.props.grid[1]
406-
? clientY
408+
clientY = Math.abs(clientY - parseInt(this.state.clientY, 10)) >= this.props.grid[1]
409+
? (parseInt(this.state.clientY, 10) + (this.props.grid[1] * directionY))
407410
: this.state.clientY;
408411
}
409412

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,14 @@
2828
},
2929
"homepage": "https://github.com/mzabriskie/react-draggable",
3030
"devDependencies": {
31-
"jsx-loader": "^0.11.0",
31+
"jsx-loader": "^0.12.0",
3232
"karma": "^0.12.19",
3333
"karma-chrome-launcher": "^0.1.4",
3434
"karma-cli": "0.0.4",
3535
"karma-firefox-launcher": "^0.1.3",
3636
"karma-jasmine": "^0.1.5",
3737
"karma-webpack": "^1.2.1",
38-
"react": "^0.11.1",
38+
"react": "^0.12.0",
3939
"reactify": "^0.17.1",
4040
"uglify-js": "^2.4.15",
4141
"webpack": "^1.3.2-beta8",

0 commit comments

Comments
 (0)