CosmicMind / Motion

A library used to create beautiful animations and transitions for iOS.

Home Page:http://cosmicmind.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

issue with interactive transition

Banck opened this issue · comments

Hello!
Brach: Development.
Version: 2.0.0
Issue: I have a UINavigationController with some viewControllers. And I have a PhotoController which will dismiss interactively.
PhotoController has modalPresentationStyle = .custom.
Simple code for interactive dismiss:

func pan() {
        let translation = panGR.translation(in: nil)
        let progress = abs(translation.y / 2 / collectionView!.bounds.height)
        switch panGR.state {
        case .began:
            motionDismissViewController()
        case .changed:
            MotionTransition.shared.update(TimeInterval(progress))
            if let cell = collectionView?.visibleCells[0]  as? ScrollingImageCell {
                let currentPos = CGPoint(x: translation.x + view.center.x, y: translation.y + view.center.y)
                MotionTransition.shared.apply(modifiers: [.position(currentPos)], to: cell.imageView)
            }
        default:
            if progress + abs(panGR.velocity(in: nil).y) / collectionView!.bounds.height > 0.3 {
                MotionTransition.shared.finish()
            } else {
                MotionTransition.shared.cancel()
            }
        }
    }

The issue is if MotionTransition.shared.cancel() is called, then viewWillDisappear will be called on the previous controller and after that viewWillDisappear and viewWillAppear won't be called on every controllers in the UINavigationController (which was under PhotoController).

If comment these lines in MotionTransition.swift :
telegram-cloud-file-2-257907020-90574-3821470602619572564
then all is fine.

Could you please check. Thanks

Thank you for bringing this to our attention. @OrkhanAlikhanov will you take a look at this? Thanks buddy!

Hey @Banck, this should be fixed in #63. Thank you for your patience :)

@OrkhanAlikhanov When using modalPresentationStyle = .overCurrentContext, your PR fix is not working, I've got the same case, in .custom, it will work fine

@mumensh Can you please send a sample app here?

@OrkhanAlikhanov Here is a sample for the issue, try run the project and tap on the images then try to dismiss them by panning in the first tab, then go to the second tap and try to tap on the images, it will not work. if you change the modalPresentationStyle to .custom, it will work fine.

motionBug.zip

Hey @mumensh I played with your project.

  1. I believe you wanted to use .overFullScreen not .overCurrentContext.
  2. There is no need to break at the end of each case in swift.
  3. I removed your SecondViewController.
  4. I renamed your ThirdViewController to ImageViewController.
  5. #63 Is meant to fix unbalanced calls appearance method logs issue, which is not an issue for your case.

motionBug.zip

@OrkhanAlikhanov Thank you very much :)