Last active
May 31, 2022 08:31
-
-
Save dilrajsingh1997/ae87af611c3a35c9156a9966631c1cb8 to your computer and use it in GitHub Desktop.
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
val height = with(LocalDensity.current) { | |
LocalConfiguration.current.screenHeightDp.dp.toPx() | |
} | |
val position = remember { | |
mutableStateOf(1) | |
} | |
val yOffset by animateFloatAsState( | |
targetValue = if (position.value == 0) { | |
height / 2 | |
} else { | |
height | |
}, | |
animationSpec = tween( | |
durationMillis = 3000, | |
easing = FastOutSlowInEasing | |
) | |
) | |
Text( | |
text = "hi", | |
modifier = Modifier.offset { | |
IntOffset(x = 200, y = yOffset.toInt()) | |
} | |
) | |
Button( | |
onClick = { | |
position.value = (position.value + 1) % 2 | |
}, | |
modifier = Modifier.align(Alignment.BottomCenter) | |
) { | |
Text(text = "Animate") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment