@@ -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
0 commit comments