Skip to content

Commit

Permalink
Fix UIView scroll offset max clamping
Browse files Browse the repository at this point in the history
Take the view's bounds into effect when clamping the maximum offset value
  • Loading branch information
dellisd committed Oct 28, 2024
1 parent efe412e commit b889519
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -140,12 +140,15 @@ internal class YogaUIView : UIScrollView(cValue { CGRectZero }), UIScrollViewDel
override fun scrollViewDidScroll(scrollView: UIScrollView) {
val onScroll = onScroll
if (onScroll != null) {
val size = scrollView.bounds.useContents {
if (isColumn()) size.height else size.width
}
val max = scrollView.contentSize.useContents {
if (isColumn()) height else width
}
val offset = scrollView.contentOffset.useContents {
if (isColumn()) y else x
}.coerceIn(minimumValue = 0.0, maximumValue = max)
}.coerceIn(minimumValue = 0.0, maximumValue = max - size)
onScroll(Px(offset))
}
}
Expand Down

0 comments on commit b889519

Please sign in to comment.