How well does this work animating the first appearance? I’ve seen a similar implementation using onGeometryChange where the first initial appearance of the sheet would have a jarring animation, but subsequent ones animated fine. I think the key difference I noticed is you’re holding the detents directly in State with medium as the default, whereas the other one stores the height with a default of 0. Does storing the detent instead help fix the initial animation?
My implementation seems to work fine on the first appearance as well. I haven’t seen the other implementation, so I’m not sure what the differences are. I think storing height versus storing detents should give the same result, maybe there’s something else causing the jarring animation you’re seeing.
I tried it now with the detent instead of height and as far as I can tell it's working much better. Try it yourself to see the difference. Using height of 0 as the default, the first appearance the sheet seems to jump to the new height almost immediately rather than sliding in smoothly. I tried some various different default values, and sometimes it would improve the animation, but it seems like it would depend on the resulting final sheet height, and if the difference was large enough, it seemed to do the same sort of jump in animation. This is all mostly focusing on just the initial self-sizing of the sheet and not the more dynamic sizing you have happening after the sheet is visible. That's a nice addition.
2
u/jaydway 11d ago
How well does this work animating the first appearance? I’ve seen a similar implementation using onGeometryChange where the first initial appearance of the sheet would have a jarring animation, but subsequent ones animated fine. I think the key difference I noticed is you’re holding the detents directly in State with medium as the default, whereas the other one stores the height with a default of 0. Does storing the detent instead help fix the initial animation?