Created
January 19, 2026 14:44
-
-
Save mutkuensert/36cb2f4e7e54664a67ea8e3c58afaf68 to your computer and use it in GitHub Desktop.
A composable that indicates to the user there is a scrollable content
This file contains hidden or 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
| @Composable | |
| fun ScrollHintEffect(content: @Composable (scrollState: ScrollState) -> Unit) { | |
| var hasHinted by rememberSaveable { mutableStateOf(false) } | |
| val density = LocalDensity.current | |
| val scrollState = rememberScrollState() | |
| LaunchedEffect(Unit) { | |
| delay(300) | |
| if (!hasHinted) { | |
| hasHinted = true | |
| repeat(2) { | |
| scrollState.animateScrollBy( | |
| value = with(density) { 32.dp.toPx() }, | |
| animationSpec = tween() | |
| ) | |
| scrollState.animateScrollBy( | |
| value = -with(density) { 32.dp.toPx() }, | |
| animationSpec = tween() | |
| ) | |
| } | |
| } | |
| } | |
| content.invoke(scrollState) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment