apptekstudios / ASCollectionView

A SwiftUI collection view with support for custom layouts, preloading, and more.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

onReachedBoundary is not called if edgesIgnoringSafeArea is set

akolov opened this issue · comments

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:

height: contentSize.height + adjustedContentInset.bottom + contentInset.top) // NOTE: the adjusted top inset intentionally left out, as SwiftUI uses a negative contentOffset to display the nav bar (doesn't affect content size)

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:

let scrollableVertically = scrollView.contentSizePlusInsets.height > scrollView.frame.size.height
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:

  • 11.5 (11E608c)

Simulator, Device, Both?

  • Both simulator and device running iOS 13.5

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 👍