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

Reload 2 items toggle state in same section causing the whole section to reload( below iOS 13 ) #131

Open
rafattouqir opened this issue Dec 15, 2019 · 0 comments

Comments

@rafattouqir
Copy link

Reloading "state only values of specific items in horizontal section" is causing the section to scrollto first (it's reloading whole section)

        ///on cell did select
        guard var currentSnapshot = dataSource?.snapshot() else { return }
        var itemsToReload:[SomeClassTypeHashable] = []
        //toggle state of  current cell
        let selectedItem = currentSnapshot.sectionIdentifiers[indexPath.section].items[indexPath.item]
        if var item = selectedItem as? Playable{
            item.isPlaying = !item.isPlaying
            itemsToReload.append(selectedItem)
        }
        //reset state of all other cells as playing capabilities will only be available at one cell at a time.
        currentSnapshot.sectionIdentifiers[indexPath.section].items.filter({(($0 as? Playable)?.isPlaying ?? false) == true && $0 != selectedItem}).forEach({
            var prevItem = ($0 as! Playable)
            prevItem.isPlaying = false
            itemsToReload.append(castedPrevItem as! SomeClassTypeHashable)
        })
        
        currentSnapshot.reloadItems(itemsToReload)
        
        dataSource?.apply(currentSnapshot)

Works perfectly in iOS 13 but scrolling issues are prominent in below versions of iOS 13.

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