Skip to content

Commit

Permalink
Fix card swipe animation to match swiping direction(#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
sangcomz committed Feb 2, 2020
1 parent 9db743f commit 42ae3dd
Showing 1 changed file with 8 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class ShySharkLayoutManager(private val internalDragListener: OnInternalDragList

changeDefaultElevation(ViewCompat.getElevation(view))

if (isTopView) setTopViewOnTouchListener(view)
if (isTopView) view.postDelayed({ setTopViewOnTouchListener(view) }, 100)

setElevation(
view,
Expand Down Expand Up @@ -237,10 +237,7 @@ class ShySharkLayoutManager(private val internalDragListener: OnInternalDragList
}
MotionEvent.ACTION_MOVE -> {
internalDragListener.onDrag(v, rawX + event.rawX, rawY + event.rawY)
transitionAnimation(
v,
rawX + event.rawX, rawY + event.rawY
)
transitionAnimation(v, rawX + event.rawX, rawY + event.rawY)
}
}
true
Expand Down Expand Up @@ -282,23 +279,22 @@ class ShySharkLayoutManager(private val internalDragListener: OnInternalDragList
restoreScaleAnimation(secondView, autoDraggingAnimationDuration)
}

val value = 3f

when (direction) {
SWIPE_TOP -> {
swipedAnimation(swipedView.x, swipedView.y - swipedView.height)
swipedAnimation(swipedView.x * value, swipedView.y - swipedView.height)
}
SWIPE_BOTTOM -> {
swipedAnimation(swipedView.x, swipedView.y + swipedView.height)
swipedAnimation(swipedView.x * value, swipedView.y + swipedView.height)
}
SWIPE_LEFT -> {
swipedAnimation(swipedView.x - swipedView.width, swipedView.y)
swipedAnimation(swipedView.x - swipedView.width, swipedView.y * value)
}
SWIPE_RIGHT -> {
swipedAnimation(swipedView.x + swipedView.width, swipedView.y)

swipedAnimation(swipedView.x + swipedView.width, swipedView.y * value)
}
}


}

private fun validateScale(value: Float): Float {
Expand Down

0 comments on commit 42ae3dd

Please sign in to comment.