Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ASCollectionNode] More info on changes in #797 #936

Open
flovouin opened this issue May 23, 2018 · 0 comments
Open

[ASCollectionNode] More info on changes in #797 #936

flovouin opened this issue May 23, 2018 · 0 comments

Comments

@flovouin
Copy link
Contributor

Hi guys,

I recently posted an issue about a crash caused by #797 that has since been solved. However this same PR also had an undesirable effect on some of my ASCollectionNode layout and behaviour.

The original problem I had solved a long time ago was: "How to scroll to a given cell (or page, with isPagingEnabled) as soon as the data has been loaded?"
I remember asking this question on Slack and experimenting with several solutions including using reloadData, waitUntilAllUpdatesAreProcessed, etc. Eventually what was working 100% for me was something along the lines of:

override func interfaceStateDidChange(_ newState: ASInterfaceState, from oldState: ASInterfaceState) {
    super.interfaceStateDidChange(newState, from: oldState)

    if !oldState.contains(.inHierarchy), newState.contains(.inHierarchy), let index = self.preLoadIndex {
        self.preLoadIndex = nil
        self.collectionNode.scrollToItem(at: IndexPath(item: index, section: 0), at: [], animated: animated)
    }
}

This was until #797, which introduces this change. Now some of my collection nodes no longer scroll to the correct index. Reverting this single line solves the problem for me, but I had two questions:

  • First of all, are there any other ways of reliably scrolling to a given cell as soon as the collection loads and is displayed? This might avoid finding a workaround/fix altogether.
  • Out of curiosity (and interest!) why was this change made? If the collection node is not part of a range managed hierarchy, why shouldn't the initial data load be triggered at this moment?

Maybe @appleguy could help me figure this out? 😊

Cheers,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant