Skip to content

Commit

Permalink
Clamp scroll callback offset to content size maximum (#2334)
Browse files Browse the repository at this point in the history
  • Loading branch information
dellisd authored Sep 26, 2024
1 parent 501ad05 commit a2e645f
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,12 @@ internal class YogaUIView(
override fun scrollViewDidScroll(scrollView: UIScrollView) {
val onScroll = onScroll
if (onScroll != null) {
val max = scrollView.contentSize.useContents {
if (isColumn()) height else width
}
val offset = scrollView.contentOffset.useContents {
if (isColumn()) y else x
}.coerceAtLeast(0.0)
}.coerceIn(minimumValue = 0.0, maximumValue = max)
onScroll(Px(offset))
}
}
Expand Down

0 comments on commit a2e645f

Please sign in to comment.