HeroTransitions / Hero

Elegant transition library for iOS & tvOS
https://HeroTransitions.github.io/Hero/
MIT License
22.06k stars 1.73k forks source link

My animation is all over the place and I don't know why #556

Closed pelayomartinez closed 2 years ago

pelayomartinez commented 6 years ago

I tried creating a hero zoom animation for a smooth transition between two view controllers, but it was not smooth at all (See this screen recording)

Anyone able to give me some insight I would really appreciate it! TIA

My Code:

` //My code

    let cardHandled = sender.view as! DraggableView

    let storyboard = UIStoryboard(name: "Main", bundle: nil)
    let nextViewController = storyboard.instantiateViewController(withIdentifier: "pictureViewer") as! MultipleDressScreenViewController
    let _ = nextViewController.view.description

    //profileView contains the name, location and image.
    cardHandled.profileView.heroID = "pview"
    cardHandled.dressImageView.heroID = "imageView" //the main image
    cardHandled.dressName.heroID = "dressName"
    cardHandled.dressDescription.heroID = "dressDescription"

    //nextViewController.profileName.heroID = "pname"
    nextViewController.profileView.heroID = "pview"
    //nextViewController.profileImage.heroID = "pcircle"
    //nextViewController.locationLabel.heroID = "plocation"
    nextViewController.dressImagesCollectionView.heroID = "imageView"
    nextViewController.dressTitle.heroID = "dressName"
    nextViewController.dressDescription.heroID = "dressDescription"

    nextViewController.isHeroEnabled = true
    self.navigationController?.isHeroEnabled = true
    self.navigationController?.heroNavigationAnimationType = .zoom
    nextViewController.doNotFade = true

    nextViewController.profileName.text = cardHandled.profileView.profileName.text
    nextViewController.profileImage.image = cardHandled.profileView.profileCircle.image
    nextViewController.locationLabel.text = cardHandled.profileView.location.text
    nextViewController.dressImagesCollectionView.currentPictures.append(cardHandled.dressImageView.image!)
    nextViewController.dressTitle.text = cardHandled.dressName.text
    nextViewController.dressDescription.text = cardHandled.dressDescription.text
    nextViewController.refToLoad = cardHandled.reference

    self.navigationController?.pushViewController(nextViewController, animated: true)`
SebastianThiebaud commented 5 years ago

I assume it's because your two view controllers don't have all the views. It's an issue I find a bit annoying with Hero... your view controller needs to create "fake" views (with alpha 0) is you want Hero to create accurate animations. It would be nice if Hero could create these fake views when they are missing in one view controller and assume they should appear/dismiss.