Reputation: 12272
I have a typical ...
"user selects one row, all other rows go away, there is now only one row in the data source, the row's new position is (obviously) now the top and only row: row X slides up to that new position"
... animation, which you do with ...
data .. update to the final data (now only ONE section)
coll.performBatchUpdates({
coll.deleteSections(removeIndexPathSections)
coll.moveSection(indexPathOfTargetRow, toSection: 0)
}) { _ in
completion()
}
Example: the rows (ie, sections) of the collection
A
B
C
D
E
(TBC typically there would be 100s of rows.) The user clicks "D" row and we get
D
ie: removeIndexPathSections
would be [0,1,2,4]
and indexPathOfTargetRow
would be 3
This works fine but if you try this in collection view what happens in detail is
the four rows fade away over the half second
the "D" row slides up to the top position over the same half-second
That's fine. But I would prefer
the four rows instantly disappear
the "D" row slides up to the top position over a half-second
I can't find a way to do this. Is it possible?
My workaround is just to run this sort of code first ..
let viz = coll.indexPathsForVisibleItems
for v in viz {
if v.section == 0 { continue }
if v.section == indexPathOfTargetRow { continue }
coll.cellForItem(at: v)?.isHidden = true
// don't forget due to this you have to unhide
// in prepareForReuse every cell type used :/
}
.. then the above code ..
.. which is a shame.
In related approaches,
perhaps there's a way to run the two animations sequentially versus simultaneously?
perhaps you can set the animation time, or, each of the two animations differently?
You can changed the peed with coll.forFirstBaselineLayout.layer.speed = ..
but I could not find how to independently change the two animations.
Any ideas ?
Upvotes: 0
Views: 45