https://kotlinlang.org logo
#compose
Title
# compose
b

Bruno_

01/06/2020, 10:20 PM
VerticalScroller no longer has
onScrolledPositionChanged
, was it removed on purpose?
a

Adam Powell

01/06/2020, 10:47 PM
The
ScrollerPosition
object that it accepts as a parameter is an
@Model
object, so its
value
property is observable for the current scroll position
👍 1
so yes, it was removed on purpose, but I'm not sure we're finalized on this particular approach as a replacement just yet. At a minimum we need the better convenience helpers to observe
@Model
changes outside of compose; it's really raw in the current artifacts
m

matvei

01/07/2020, 11:25 AM
Partial reason why it was removed: animation inside (smoothScrollTo, fling after scroll) couldn't guarantee consistency if you do something more fancy like
Copy code
onScrolledPositionChanged = { newValue ->  scrollPosition.value = calcMyCustomParallaxDelta(newValue) }
Above will work for dragging, but won't for fling/smoothScrolling. So we decide to remove inconsistency, while leaving ability to observe (just read scrollPosition.value, as Adam suggested) and explore more 🙂
b

Bruno_

01/07/2020, 5:04 PM
if it's a
@Model
, won't it have a massive impact on the performance? also, I could figure stuff out myself but I can't donwload sources, is it even possible?
m

matvei

01/07/2020, 5:12 PM
It probably will impact performance now, yes. But in this case, it's on us to fix performance, and to provide APIs that won't give false promises
Not sure about the second question 🙂