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

Animation not working for UICollectionViewDiffableDataSource #745

Open
EyalHouzz opened this issue Sep 7, 2022 · 1 comment
Open

Animation not working for UICollectionViewDiffableDataSource #745

EyalHouzz opened this issue Sep 7, 2022 · 1 comment

Comments

@EyalHouzz
Copy link

EyalHouzz commented Sep 7, 2022

What did you do?

I am trying to use Hero to animate transitions into a screen that is rendered with UICollectionView with UICollectionViewDiffableDataSource, by calling apply snapshot (NSDiffableDataSourceSnapshot)

What did you expect to happen?

To see the animation between the views that have matching hero ids

What happened instead?

The screen appears with the hero fade only
On dismissing, the hero animations works perfectly (which removes the option that ids weren't defined properly, or any other setup issue)

From my investigation, if I add a delay of 2 seconds before presenting the screen, the animation works.
I also checked and saw that the the cells still didn't render when Hero tried to animate

Also, in another screen, that works with the same lifecycle exactly but without the diffable datasource, the hero animation works!
I also tried triggering apply snapshot without animations, or with the iOS 15 API (applySnapshotWithReloadData)

Is there a way to get this to work?

General Information

  • Hero Version:
    latest

  • iOS Version(s):
    15.6.1

  • Swift Version:
    5

  • Devices/Simulators:
    iPhone 13 (real device)

@SubvertDev
Copy link

I'm having similar issues, animating an image from a collectionView to an image in a collectionView on another screen that uses DiffableDataSource wasn't working until I've wrapped my pushViewController call into Task { @MainActor in ... } (or just DispatchQueue.main.asyncAfter(deadline: .now() + 0.01)), but it doesn't seem like a robust solution.

Also, this problem happens only on a real device, simulator works fine without these workarounds.

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

2 participants