File tree Expand file tree Collapse file tree
JetLagged/app/src/main/java/com/example/jetlagged Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -158,17 +158,13 @@ fun HomeScreenDrawer(windowSizeClass: WindowSizeClass) {
158158 } else {
159159 0f
160160 }
161- val canReachTargetWithDecay =
162- (
163- targetOffsetX > actualTargetX &&
164- velocity > 0f &&
165- actualTargetX > 0f
166- ) ||
167- (
168- targetOffsetX < actualTargetX &&
169- velocity < 0 &&
170- actualTargetX == 0f
171- )
161+ val canReachTargetWithDecay = if (actualTargetX > 0f ) {
162+ // We are aiming for the open state, check if the fling is strong enough to overshoot.
163+ velocity > 0f && targetOffsetX > actualTargetX
164+ } else {
165+ // We are aiming for the closed state, check if the fling is strong enough to overshoot.
166+ velocity < 0f && targetOffsetX < actualTargetX
167+ }
172168 if (canReachTargetWithDecay) {
173169 translationX.animateDecay(
174170 initialVelocity = velocity,
You can’t perform that action at this time.
0 commit comments