Skip to content

Commit

Permalink
Fix scrollview content staying non-interactive after slowly swiping d…
Browse files Browse the repository at this point in the history
…own (#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 <[email protected]>
  • Loading branch information
sgade and sgade authored Jul 1, 2023
1 parent e7d0a72 commit 7511ce5
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion Sources/Core.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down

0 comments on commit 7511ce5

Please sign in to comment.