Is there a way to fast-forward a compose scene by ...
# compose
f
Is there a way to fast-forward a compose scene by a certain amount? Basically I want to make a scrub bar for an animation defined with any of the animation APIs and normal coroutine functions, scrubbing forward requires forcing multiple frames in one frame and scrubbing backwards requires starting over from the beginning (unless there's something clever I can do by saving snapshot states?)
w
You could technically control the recomposition clock and skip it ahead to where you want the animation to pause at. Rewinding would require fully resetting the view and re-forwarding though, since frames can't go backwards.
f
Do I have to provide my own
Recomposer
for that to work? It seems to provide a its own MonotonicFrameClock that overrides any already in scope
w
Yes, you'll need that to inject your own clock so that it prefers that one when creating any effects. If you're in Android this isn't that difficult because you can provide your own context when creating a ComposeView. If you're doing this in CMP and need to replace a part of your hierarchy with this time controlled section, I'm not sure how you'd do that.
f
I found if I made my own PlatformLayersComposeScene I could pass it my own FrameRecomposer which lets me control the timing of recomposition. Is
Copy code
Modifier.drawBehind{
    drawIntoCanvas {
        scene.draw(it)
    }
}
really the best way to draw it on the screen, or is there some sort of compose scene hoster composable I should be using?
It took a little thinking but I managed to get something that works, I just decoupled its frame clock from the real time clock and step forward one frame at a time and it works now
nice spin 1