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

Missing callback when animator finished running. #42

Open
strangeliu opened this issue Apr 23, 2019 · 5 comments
Open

Missing callback when animator finished running. #42

strangeliu opened this issue Apr 23, 2019 · 5 comments

Comments

@strangeliu
Copy link

use changedValue == targetValue is incorrect for some reason.

@timdonnelly
Copy link
Owner

Thanks for opening @strangeliu.

Can you please provide mode information on what you were trying to do, what you expected to happen, and what actually happened?

@strangeliu
Copy link
Author

In the version v2.2.0, we can run an animation with AnimationRunner and set a callback when it finished running

let runner = AnimationRunner(animation: animation)
runner.onCompletion { _ in
    print("animation finished running")
}

After upgrade to version 3.0.0, The AnimationRunner is removed, so i use animator.animate(to: targetValue, duration: duration) to run an animation, but there's no way to know when the animation is finished running.

@timdonnelly
Copy link
Owner

Got it – would adding back an optional completion argument be helpful for the methods on Animator?

public enum CompletionReason {
    case finished
    case interrupted
}

public func animate(
    to finalValue: Value, 
    duration: Double, 
    timingFunction: TimingFunction = .swiftOut,
    completion: @escaping (CompletionReason) -> Void)

public func simulate<T>(
    using function: T, 
    initialVelocity: T.Value,
    completion: @escaping (CompletionReason) -> Void = { _ in }) where Value == T.Value, T : SimulationFunction

public func simulate<T>(
    using function: T,
    completion: @escaping (CompletionReason) -> Void = { _ in }) where Value == T.Value, T : SimulationFunction

@timdonnelly
Copy link
Owner

Most of the previously public API was unused, so v3 moves toward a much simpler model – the advent of types like UIViewPropertyAnimator mean that Advance is primarily useful for spring physics instead of general purpose animation. (Technically UIViewPropertyAnimator can use springs to control timing, but it's not as well suited to general purpose springs)

@guidedways
Copy link

Any update on this?

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

No branches or pull requests

3 participants