Giter Club home page Giter Club logo

Comments (9)

hfrahmann avatar hfrahmann commented on July 18, 2024

I don't understand what you mean. Can you explain your problem? ;-)

Maybe the following code helps:

UIView.performWithoutAnimation {
  // updating the layout
}

from hfcardcollectionviewlayout.

Alex293 avatar Alex293 commented on July 18, 2024

In my app I have sometimes background update to my collection data. When this occurs I use collectionView.performBatchUpdates. I'd like to do this without calling animations.

I think this as more to to with the collection than your layout but I'm looking for pointers

from hfcardcollectionviewlayout.

Alex293 avatar Alex293 commented on July 18, 2024

UIView.performWithoutAnimation {
// updating the layout
}
is a good start.

from hfcardcollectionviewlayout.

Alex293 avatar Alex293 commented on July 18, 2024

The main issue I have is that the selection is not kept when I do an update. I tried to go around with disabling animation the manually selecting the previous selected item but the are still small flash.

My goal is when there is no selection it add a card like in the demo but when there is a selection the selection not changed and the row is added silently

from hfcardcollectionviewlayout.

Alex293 avatar Alex293 commented on July 18, 2024

An easy way to see what I'm fighting in the example is to replace :
if(self.colorArray.count == 1 || self.cardCollectionViewLayout!.revealedIndex >= 0) {
self.cardCollectionViewLayout?.unrevealCard(completion: {
self.colorArray.insert(self.getRandomColor(), at: index)
self.collectionView?.insertItems(at: [IndexPath(item: index, section: 0)])
})
} else {
self.colorArray.insert(self.getRandomColor(), at: index)
self.collectionView?.insertItems(at: [IndexPath(item: index, section: 0)])
}
with :
self.colorArray.insert(self.getRandomColor(), at: index)
self.collectionView?.insertItems(at: [IndexPath(item: index, section: 0)])

from hfcardcollectionviewlayout.

hfrahmann avatar hfrahmann commented on July 18, 2024

OK, now i know what you mean. :-)
But it's not so simple to fix.

from hfcardcollectionviewlayout.

hfrahmann avatar hfrahmann commented on July 18, 2024

To achieve the right behavior I have to create my own UICollectionView (extend) and overwrite some methods (insertItems(at indexPaths: [IndexPath])).

from hfcardcollectionviewlayout.

Alex293 avatar Alex293 commented on July 18, 2024

Can you post what works for you I'll extend the collection in my project so you don't have to change the structure of your lib

from hfcardcollectionviewlayout.

hfrahmann avatar hfrahmann commented on July 18, 2024

If you only have the problem for inserting items, with the new version you can use the HFCardCollectionView or copy the call of the helper method to your own class.

class HFCardCollectionView: UICollectionView {

    override func insertItems(at indexPaths: [IndexPath]) {
        if let collectionViewLayout = self.collectionViewLayout as? HFCardCollectionViewLayout {
            collectionViewLayout.willInsert(indexPaths: indexPaths)
        }
        super.insertItems(at: indexPaths)
    }

}

I hope this helps. ;-)

And you don't need the UIView.performWithoutAnimation{} method if you just insert new items.

from hfcardcollectionviewlayout.

Related Issues (14)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.