How can I translate a composable's visible position without snapping to whole pixels -- i.e. fractional offsets.
The pixel snapping causes animation settling to be jittery.
Here's an example - you can see that the red box does not move smoothly:
To ensure your app does as little as possible while animating, choose the lambda version of a
Modifier
where possible. This skips recomposition and performs the animation outside of the composition phase, otherwise use
Modifier.graphicsLayer{ }
, as this modifier always runs in the draw phase. For more information on this, see the deferring reads section in the performance documentation.
👍 1
r
romainguy
05/24/2024, 2:15 PM
More importantly remember that layout is done in integer pixels, but drawing can be done fractionally. Hence the suggested use of graphicsLayer here.
👍 1
r
rob42
05/24/2024, 3:25 PM
Thanks for the advice re: graphicsLayer + translation.
I'm finding the same behaviour there -- even if I specify a fractional translation, it gets drawn at an integer offset
rob42
05/24/2024, 3:26 PM
Errr, yet somehow when I just re-attempted this, it is drawn fractionally. Oops, guess I screwed something up earlier.
Thank you 🙂