@@ -683,6 +683,44 @@ describe('react-draggable', function () {
683683
684684 simulateMovementFromTo ( drag , 200 , 200 , 300 , 300 ) ;
685685 } ) ;
686+
687+ it ( 'should call back with correct position when parent element is 2x scaled' , function ( ) {
688+ function onDrag ( event , data ) {
689+ // visually it will look like 100, because parent is 2x scaled
690+ assert ( data . x === 50 ) ;
691+ assert ( data . y === 50 ) ;
692+ assert ( data . deltaX === 50 ) ;
693+ assert ( data . deltaY === 50 ) ;
694+ assert ( data . node === ReactDOM . findDOMNode ( drag ) ) ;
695+ }
696+ drag = TestUtils . renderIntoDocument (
697+ < Draggable onDrag = { onDrag } scale = { 2 } >
698+ < div />
699+ </ Draggable >
700+ ) ;
701+
702+ // (element, fromX, fromY, toX, toY)
703+ simulateMovementFromTo ( drag , 0 , 0 , 100 , 100 ) ;
704+ } ) ;
705+
706+ it ( 'should call back with correct position when parent element is 0.5x scaled' , function ( ) {
707+ function onDrag ( event , data ) {
708+ // visually it will look like 100, because parent is 0.5x scaled
709+ assert ( data . x === 200 ) ;
710+ assert ( data . y === 200 ) ;
711+ assert ( data . deltaX === 200 ) ;
712+ assert ( data . deltaY === 200 ) ;
713+ assert ( data . node === ReactDOM . findDOMNode ( drag ) ) ;
714+ }
715+ drag = TestUtils . renderIntoDocument (
716+ < Draggable onDrag = { onDrag } scale = { 0.5 } >
717+ < div />
718+ </ Draggable >
719+ ) ;
720+
721+ // (element, fromX, fromY, toX, toY)
722+ simulateMovementFromTo ( drag , 0 , 0 , 100 , 100 ) ;
723+ } ) ;
686724 } ) ;
687725
688726 describe ( 'DraggableCore callbacks' , function ( ) {
@@ -703,6 +741,44 @@ describe('react-draggable', function () {
703741 // (element, fromX, fromY, toX, toY)
704742 simulateMovementFromTo ( drag , 0 , 0 , 100 , 100 ) ;
705743 } ) ;
744+
745+ it ( 'should call back with correct position when parent element is 2x scaled' , function ( ) {
746+ function onDrag ( event , data ) {
747+ // visually it will look like 100, because parent is 2x scaled
748+ assert ( data . x === 50 ) ;
749+ assert ( data . y === 50 ) ;
750+ assert ( data . deltaX === 50 ) ;
751+ assert ( data . deltaY === 50 ) ;
752+ assert ( data . node === ReactDOM . findDOMNode ( drag ) ) ;
753+ }
754+ drag = TestUtils . renderIntoDocument (
755+ < DraggableCore onDrag = { onDrag } scale = { 2 } >
756+ < div />
757+ </ DraggableCore >
758+ ) ;
759+
760+ // (element, fromX, fromY, toX, toY)
761+ simulateMovementFromTo ( drag , 0 , 0 , 100 , 100 ) ;
762+ } ) ;
763+
764+ it ( 'should call back with correct position when parent element is 0.5x scaled' , function ( ) {
765+ function onDrag ( event , data ) {
766+ // visually it will look like 100, because parent is 0.5x scaled
767+ assert ( data . x === 200 ) ;
768+ assert ( data . y === 200 ) ;
769+ assert ( data . deltaX === 200 ) ;
770+ assert ( data . deltaY === 200 ) ;
771+ assert ( data . node === ReactDOM . findDOMNode ( drag ) ) ;
772+ }
773+ drag = TestUtils . renderIntoDocument (
774+ < DraggableCore onDrag = { onDrag } scale = { 0.5 } >
775+ < div />
776+ </ DraggableCore >
777+ ) ;
778+
779+ // (element, fromX, fromY, toX, toY)
780+ simulateMovementFromTo ( drag , 0 , 0 , 100 , 100 ) ;
781+ } ) ;
706782 } ) ;
707783
708784
0 commit comments