Skip to content

Commit 6e93efc

Browse files
committed
Fix drawer animation logic
The drawer animation logic had a bug where it would not properly animate the drawer to the correct position. This commit fixes the issue by adjusting the conditions that determine whether the drawer can reach the target position with decay. Specifically, it checks if `actualTargetX > 0f` instead of `targetDifference > 0f` and `actualTargetX == 0f` instead of `targetDifference < 0f`.
1 parent 17301db commit 6e93efc

1 file changed

Lines changed: 2 additions & 4 deletions

File tree

JetLagged/app/src/main/java/com/example/jetlagged/JetLaggedDrawer.kt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -158,18 +158,16 @@ fun HomeScreenDrawer(windowSizeClass: WindowSizeClass) {
158158
} else {
159159
0f
160160
}
161-
// checking if the difference between the target and actual is + or -
162-
val targetDifference = (actualTargetX - targetOffsetX)
163161
val canReachTargetWithDecay =
164162
(
165163
targetOffsetX > actualTargetX &&
166164
velocity > 0f &&
167-
targetDifference > 0f
165+
actualTargetX > 0f
168166
) ||
169167
(
170168
targetOffsetX < actualTargetX &&
171169
velocity < 0 &&
172-
targetDifference < 0f
170+
actualTargetX == 0f
173171
)
174172
if (canReachTargetWithDecay) {
175173
translationX.animateDecay(

0 commit comments

Comments
 (0)