Hero: Button above image view flashing during modal transition

Created on 1 Mar 2018  路  4Comments  路  Source: HeroTransitions/Hero

We are considering using Hero for transitions within our application and have been trialing it out today.

We are having an issue with a close button flashing during a modal presentation of a details view controller.

The rootVC is a collection view with cells in that once tapped open a details view. The collection view cells have an image and 3 labels which are also present on the details screen. These are matched up with hero IDs and animate as expected. On the details screen there is a dismiss button in the top left (on top of the imageView). This does not have heroID as it is not on ht previous view controller ad we just expect it to fade in.

As you can see in the video the button appears to fade in then become 100% visible before fading in again causing a sort of flash.

Any suggestions to what we could be doing wrong?

Thanks in advanced for you help and working on this library.

RootVC
``` func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell: DealCardCellCollectionViewCell = collectionView.dequeueReusableCell(forIndexPath: indexPath)
let deal = deals[indexPath.row]
cell.configure(for: deal)

    cell.dealCard.imageView.hero.id = deal.id + "_offerImage"
    cell.dealCard.titleLabel.hero.id = deal.id + "_offerTitle"
    cell.dealCard.descriptionLabel.hero.id = deal.id + "_offerDescription"

func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
    let deal = deals[indexPath.row]

    let detailsVC = OfferDetailsViewController.makeFromStoryboard()
    detailsVC.deal = deal
    detailsVC.hero.isEnabled = true
    self.present(detailsVC, animated: true, completion: nil)
}

// called from viewDidLoad
private func configureHeroIdentifiers() {
imageView.hero.id = deal.id + "_offerImage"
titleLabel.hero.id = deal.id + "_offerTitle"
descriptionLabel.hero.id = deal.id + "_offerDescription"
}
```

ezgif-1-e92ff8d696

screen shot 2018-03-01 at 01 18 01

Most helpful comment

@bencallis Checkout this post that I just wrote. http://lkzhao.com/2018/03/02/hero-useglobalcoordinatespace-explained.html

All 4 comments

Give the button these modifiers: .fade, .useGlobalCoordinateSpace

Thanks useGlobalCoordinateSpace seems to be the magic modifier. Could you give me an explanation of what the flag does?

I have created custom transitions before so I would guess that this flag brings a snapshot of the view out into the containing view that performs the transition. Is that roughly right?

@bencallis Checkout this post that I just wrote. http://lkzhao.com/2018/03/02/hero-useglobalcoordinatespace-explained.html

Thanks very much for that!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

cristinaITdeveloper picture cristinaITdeveloper  路  4Comments

patchthecode picture patchthecode  路  4Comments

lkzhao picture lkzhao  路  5Comments

czater picture czater  路  3Comments

josmanperez picture josmanperez  路  3Comments