-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MP-5177] tabBar center animation internal 삭제
- Loading branch information
1 parent
6c83e9b
commit 7605f71
Showing
3 changed files
with
16 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
designsystem/src/main/java/net/deali/designsystem/util/animation/Animation.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package net.deali.designsystem.util.animation | ||
|
||
import androidx.compose.foundation.gestures.animateScrollBy | ||
import androidx.compose.foundation.lazy.LazyListState | ||
|
||
suspend fun LazyListState.animateScrollAndCentralizeItem(index: Int) { | ||
val itemInfo = this.layoutInfo.visibleItemsInfo.firstOrNull { it.index == index } | ||
if (itemInfo != null) { | ||
val center = layoutInfo.viewportEndOffset / 2 | ||
val childCenter = itemInfo.offset + itemInfo.size / 2 | ||
animateScrollBy((childCenter - center).toFloat()) | ||
} else { | ||
animateScrollToItem(index) | ||
} | ||
} |