@@ -55,11 +55,14 @@ export default function injectDependencies( Animated, PanResponder ){
5555 constructor ( props ) {
5656 super ( props )
5757
58+ let { x = 0 , y = 0 } = props . initialPosition
59+
5860 // In case animatedValueXY is not given
59- this . animated = new Animated . ValueXY ( 0 , 0 )
61+ this . animated = new Animated . ValueXY ( { x , y } )
6062
6163 // This guy will apply all the physics
6264 this . animator = this . createAnimator ( props )
65+ this . animator . debug = false
6366
6467 // Cache when the view is inside of an alert area
6568 this . insideAlertAreas = { }
@@ -76,9 +79,11 @@ export default function injectDependencies( Animated, PanResponder ){
7679 this . setPropBehaviours ( { } , props )
7780
7881 // Set initial position
79- let { x, y} = this . getAnimated ( props )
80- x . setValue ( props . initialPosition . x )
81- y . setValue ( props . initialPosition . y )
82+ let animated = this . getAnimated ( props )
83+ animated . x . setValue ( x )
84+ animated . y . setValue ( y )
85+ animated . x . _startingValue = x
86+ animated . x . _startingValue = y
8287
8388 // Save the last animation end position to report good coordinates in the events
8489 this . lastEnd = { ...this . initialPosition }
@@ -141,7 +146,7 @@ export default function injectDependencies( Animated, PanResponder ){
141146 animate ( dx , dy ) {
142147 if ( ! dx && ! dy ) return
143148 let animated = this . getAnimated ( )
144- console . log ( dx + animated . x . _value + animated . x . _offset )
149+ console . log ( dx + animated . x . _value + animated . x . _offset , this . animator . physicsObject )
145150
146151 let { x, y} = this . getTranslation ( )
147152 this . setTranslation ( x + dx , y + dy )
@@ -228,11 +233,10 @@ export default function injectDependencies( Animated, PanResponder ){
228233 }
229234
230235 onDragging ( { dx, dy} ) {
231- let pos = this . getTranslation ( )
232- let x = dx + pos . x
233- let y = dy + pos . y
234-
235- console . log ( this . dragBoundaries . minPoint )
236+ let x = dx + this . lastEnd . x
237+ let y = dy + this . lastEnd . y
238+
239+ console . log ( 'diff' , dx , dy )
236240
237241 let { minPoint, maxPoint} = this . dragBoundaries
238242 if ( ! this . props . verticalOnly ) {
@@ -333,15 +337,11 @@ export default function injectDependencies( Animated, PanResponder ){
333337 }
334338 }
335339
336- setInitialPosition ( initialPosition ) {
337- this . initialPosition = initialPosition ;
338- this . setTranslation ( initialPosition )
339- }
340-
341340 setVelocity ( velocity ) {
342341 if ( this . dragBehavior ) return ;
343- this . animator . vx = velocity . x
344- this . animator . vy = velocity . y
342+ let { physicsObject } = this . animator
343+ physicsObject . vx = velocity . x
344+ physicsObject . vy = velocity . y
345345 this . endDrag ( ) ;
346346 }
347347
@@ -367,7 +367,7 @@ export default function injectDependencies( Animated, PanResponder ){
367367 changePosition ( position ) {
368368 if ( this . dragBehavior ) return ;
369369
370- this . setTranslation ( position )
370+ this . setTranslation ( position . x , position . y )
371371 this . endDrag ( ) ;
372372 }
373373
0 commit comments