How can i start an animation from gesture detector...
# compose
g
How can i start an animation from gesture detector? I have a custom widget with Canvas and detectDragGestures, when the user finishes drag, i want to complete the gesture if it's not finished. Like if user dragged more then half way, i want to animate the full path to completion.
Copy code
val currentAnimValue = remember { Animatable(0f) }
//if i put this inside my dragEnd i get: Composable invocations can only happen from the context of a @Composable function
LaunchedEffect(value) {
        currentAnimValue.animateTo(value)
}

And if i do it, on function start, I can't set the current value, so the animation goes from initial value(0f in this case) not the current dragged value
1
In case anyone wondering:
Copy code
val coroutineScope = rememberCoroutineScope()
And then from dragEnd:
Copy code
coroutineScope.launch {
    currentAnimValue.snapTo(current)
    currentAnimValue.animateTo(targetValue)
}