HeroTransitions / Hero

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

UIVisualEffectView flashes when interactive transition is cancelled #266

Closed dkarbayev closed 6 years ago

dkarbayev commented 7 years ago

I'm using UIVisualEffectView as a view of presented view controller (VC2), so that I have blur over presenting view controller (VC1). When VC2 is presented or dismissed animatedly, blur is animated correctly, but if I cancel dismission transition blur flashes for a fraction of a second. It seems like blur's animator is being restarted when resumed without finishing.

dkarbayev commented 7 years ago

Here's how to reproduce this issue: In Menu example of HeroExamples app perform following modifications: Add view.addGestureRecognizer(UIPanGestureRecognizer(target: self, action: #selector(handlePan(gesture:)))) to viewDidLoad() method of MenuViewController. Also add this method to the same VC:

func handlePan(gesture: UIPanGestureRecognizer) {
    let translation = gesture.translation(in: nil)
    let progress = translation.y / 2 / view.bounds.height

    switch gesture.state {
    case .began:
      hero_dismissViewController()
    case .changed:
      Hero.shared.update(progress)
      Hero.shared.apply(modifiers: [.fade], to: view)
    default:
      if progress + gesture.velocity(in: nil).y / view.bounds.height > 0.3 {
        Hero.shared.finish()
      } else {
        Hero.shared.cancel()
      }
    }
  }

Now, if you run this example, start panning and release your finger after a small distance your fingertip travelled, you can see the mentioned issue.

ata-n commented 3 years ago

Any solution to this?