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

Animate view that is not paired to previous view controller #6

Closed
m-revetria opened this issue Feb 20, 2017 · 3 comments
Closed

Animate view that is not paired to previous view controller #6

m-revetria opened this issue Feb 20, 2017 · 3 comments
Assignees

Comments

@m-revetria
Copy link

Hello!

How can a view that doesn't have a motionIdentifier or simply doesn't match any identifier from the previous view controller to be animated at the same time the presentation animation happens?

I tried to add animations to this view using motionAnimations but they seem that are not executed.

I additionally tried to use view.motion(...) to animate this view in viewWillAppear but if I don''t use delay I cannot see the animations. I achieved what you can see in next gif adding a delay to the animations of this view after view controller is pushed and before it's popped. As you can notice the white view with the game's description appears after the transition has finished.

motion_animation_issue

Example code:

    /********* Pushed view controller's code *********/
    override func viewDidLoad() {
        super.viewDidLoad()
        // Set initial state for animatable views
        backgroundImage.motion(.duration(0.0), .translateX(-view.frame.width))
        tableView.motion(.duration(0.0), .translateY(view.frame.height))
    }

    override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(animated)

        let duration = 0.3
        let delay = 0.3
        let timing = MotionAnimation.timingFunction(.easeInEaseOut)

        backgroundImage.motion(.delay(delay), .duration(duration), .translateX(0), timing)
        tableView.motion(.delay(delay), .duration(duration), .translateY(0), timing)
    }

    @IBAction func backButtonDidTouch(_ sender: Any) {
        let duration = 0.3
        let timing = MotionAnimation.timingFunction(.easeInEaseOut)

        backgroundImage.motion([.duration(duration), .translateX(-view.frame.width), timing])
        tableView.motion([.duration(duration), .translateY(view.frame.height), timing])

        DispatchQueue.main.asyncAfter(deadline: .now() + duration) { [unowned self] in
            _ = self.navigationController?.popViewController(animated: true)
        }
    }
@daniel-jonathan
Copy link
Member

There is a delegation method available. I am going to test it and add a sample with the updates I am making today.

@daniel-jonathan daniel-jonathan self-assigned this Feb 20, 2017
@m-revetria m-revetria changed the title Animate view that are not paired to previous view controller Animate view that is not paired to previous view controller Feb 20, 2017
@daniel-jonathan
Copy link
Member

This is now available in the next release. Thank you!

@daniel-jonathan
Copy link
Member

The fix for this issue is in Motion 1.1.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants