Fix scrollview content staying non-interactive after slowly swiping down (#597)

This was noticed when updating contained SwiftUI views rapidly.

This change is what fixed a certain bug the scroll content can be locked at a negative offset. It was most obvious when the whitespace was large, hence the offset was something around -100.0. At the same time, the contents (like buttons) were non-interactive.

Co-authored-by: Sören Gade <soeren.gade@lichtblick.de>
This commit is contained in:
Sören Gade
2023-07-01 04:52:38 +02:00
committed by GitHub
parent e7d0a72440
commit 7511ce577d
+5 -1
View File
@@ -1079,7 +1079,11 @@ class Core: NSObject, UIGestureRecognizerDelegate {
// Must use setContentOffset(_:animated) to force-stop deceleration
guard let scrollView = scrollView else { return }
var offset = scrollView.contentOffset
setValue(contentOffset, to: &offset)
if contentOffset.y >= 0 {
setValue(contentOffset, to: &offset)
} else {
offset = CGPoint(x: 0, y: 0)
}
scrollView.setContentOffset(offset, animated: false)
}