apptekstudios / ASCollectionView

A SwiftUI collection view with support for custom layouts, preloading, and more.
MIT License
1.36k stars 160 forks source link

onReachedBoundary is not called if edgesIgnoringSafeArea is set #154

Closed akolov closed 3 years ago

akolov commented 4 years ago

Describe the bug onReachedBoundary is not called if edgesIgnoringSafeArea is set, however not using edgesIgnoringSafeArea causes large navigation title not to collapse properly.

I believe it's related to this line of code:https://github.com/apptekstudios/ASCollectionView/blob/88a0ecfaafe9128fdd59e595d55c389afe1c5999/Sources/ASCollectionView/UIKitExtensions/UIScrollView%2BConvenience.swift#L11

It mentions that SwiftUI is using negative adjusted top inset, however for me it's positive at 88.0. Which results in this condition to fail: https://github.com/apptekstudios/ASCollectionView/blob/e71eda854855629123cfb5f6d59562ea39b8f2a8/Sources/ASCollectionView/Implementation/ASCollectionView.swift#L861 because scrollView.contentSizePlusInsets.height is less than scrollView.frame.size.height:

(lldb) po scrollView.contentSizePlusInsets.height
679.0

(lldb) po scrollView.frame.size.height
729.0

Maybe this behaviour has been changed by iOS 13.5, since boundary is correctly reached when I change to use adjustedContentInset.top?

To Reproduce Steps to reproduce the behaviour:

ASCollectionView { ... }
  .onReachedBoundary { ... }
  .edgesIgnoringSafeArea(.top) // or .all

Expected behaviour onReachedBoundary is called regardless whether edgesIgnoringSafeArea is set

Xcode Version:

Simulator, Device, Both?

apptekstudios commented 4 years ago

Thank you for the PR šŸ˜„ I'm glad I'd left that comment there or would've assumed it was a mistake on my half. Sounds like the behaviour has changed - I'd just like to check backward compatibility before merging, and will hopefully have a chance later this week. Might need to check iOS version to avoid breaking behaviour on non-updated devices šŸ‘