Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: [JetLagged] canReachTargetWithDecay Condition will always be false in JetLaggedDrawer.kt #1352

Open
4 tasks done
sparrow007 opened this issue Apr 18, 2024 · 0 comments
Assignees
Labels
bug Something isn't working triage me Issue that needs to be triaged

Comments

@sparrow007
Copy link
Contributor

Is there an existing issue for this?

  • I have searched the existing issues

Is there a StackOverflow question about this issue?

  • I have searched StackOverflow

Is this an issue related to one of the samples?

  • Yes, this is a specific issue related to this samples repo.

Sample app

Other (bug not related to sample app)

What happened?

In Jetlagged we have JetLaggedDrawer.kt

                            val targetDifference = (actualTargetX - targetOffsetX)
                            val canReachTargetWithDecay =
                                (
                                    targetOffsetX > actualTargetX && velocity > 0f &&
                                        targetDifference > 0f
                                    ) ||
                                    (
                                        targetOffsetX < actualTargetX && velocity < 0 &&
                                            targetDifference < 0f
                                        )

If we check the code we can see that canReachTargetWithDecay will always be false and the reason is if targetOffsetX is greater than actualTargetX (which either be 0 or drawerWidth) then targetDifference will always in negative (<0) but in the first condition of last check targetDifference > 0f which always be <0 hence the result will be false and same goes for the second condition if targetOffsetX is smaller then targetDifference will always >0f (positive) hence second condition will always be false.

Because of this, the running conditions of different animation methods will also be not required

                            if (canReachTargetWithDecay) {
                                translationX.animateDecay(
                                    initialVelocity = velocity,
                                    animationSpec = decay
                                )
                            } else {
                                translationX.animateTo(actualTargetX, initialVelocity = velocity)
                            }

I might be wrong here Please CMIMW @riggaroo

Related PR #1174

Relevant logcat output

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
@sparrow007 sparrow007 added bug Something isn't working triage me Issue that needs to be triaged labels Apr 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working triage me Issue that needs to be triaged
Projects
None yet
Development

No branches or pull requests

2 participants