I am using animateDpAsState
animation, but there is an issue with performance. The animation is very laggy, lot of frames are dropped. When I build application with release mode, animation is running more smoothly, but it is not as good as it needs to be.
Strange thing is that when I play animation several times (for example 15 times), animation is then very smooth and everything is ok.
What could be a problem?
My code:
val contextMenuAnimation = animateDpAsState(
targetValue =
if (contextMenuOpened.value) -contextMenuWidth
else 0.dp,
animationSpec = tween()
)
. . .
Box(
modifier = Modifier
.offset(x = maxWidth + contextMenuAnimation.value)
.size(contextMenuWidth, height = maxHeight)
) {
SidePanel()
}