Closed snakemr closed 6 months ago
I have added viewport's size to the Translate
class in this PR #21.
It is available in 1.7.1 release.
Also I have checked your snippet and this looked strange to me 🤔
delay(10)
cancel()
I guess this causes de-sync when scrollbar is dragged quickly, but it is needed because without it everything get "stuck" when scrollbar is dragged during translation animation from fling. I have played around with it a little bit and looks like with NonCancelable
context it works correctly and does not get "stuck" when dragged during fling animation.
coroutineScope {
launch(NonCancellable) {
if (orientation == Orientation.Vertical)
boxState.snapTo(translate.x, scrollOffset.toFloat())
else
boxState.snapTo(scrollOffset.toFloat(), translate.y)
}
}
Just my two cents 😸
Desktop Platform of Compose Multiplatform has buil-in VerticalScrollbar and HorizontalScrollbar with their ScrollbarAdapter. I adopted it for minabox: https://gist.github.com/snakemr/fe054fc4ac1b27c3f7738638ce5ef859 usage:
Please, expose viewport's size in a MinaBoxState, so one do not have to set maxWidth/maxHeight manually.