Coder Social home page Coder Social logo

Comments (6)

u10int avatar u10int commented on September 23, 2024

@cupojoe Do you have an example where you are having this issue? To test, I added onComplete callbacks to the tweens in the SequenceViewController.swift example and the completion blocks for each tween were being triggered properly within the timeline:

let moveX = Tween(target: square).to(.x(110)).duration(0.5).ease(Easing.inOutCubic)
moveX.onStart({ (animation) in
	print("starting moveX")
}).onComplete { (animation) in
	print("moveX done")
}

let moveY = Tween(target: square).to(.y(250), .backgroundColor(.orange)).duration(0.5).ease(Easing.inOutCubic)
moveY.onStart { (animation) -> Void in
	print("starting moveY")
}.onComplete { (animation) in
	print("moveY done")
}

let resize = Tween(target: square).to(.width(200), .backgroundColor(.blue)).duration(0.5).ease(Easing.inOutCirc)
resize.onStart { (animation) -> Void in
	print("starting resize")
}.onComplete { (animation) in
	print("resize done")
}

let timeline = Timeline(tweens: [moveX, moveY, resize], align: .sequence)
timeline.yoyo().forever().onStart({ (animation) in
	print("TIMELINE start")
}).onRepeat { (animation) in
	print("TIMELINE repeat")
}

Which output:

starting moveX
TIMELINE start
moveX done
starting moveY
moveY done
starting resize
resize done
TIMELINE repeat
starting resize
resize done
starting moveY
moveY done
starting moveX
moveX done
TIMELINE repeat
starting moveX
moveX done
starting moveY
moveY done
starting resize
resize done
TIMELINE repeat
...

from kinetic.

cupojoe avatar cupojoe commented on September 23, 2024

I left the office already, but I'll send you a snippet in the morning.

Great job with the library BTW. I don't get why Apples animation api is limited to the properties they choose. It should be able to animate any value or at least be observable, right?

from kinetic.

u10int avatar u10int commented on September 23, 2024

Thanks, glad you're liking it so far! I've been making a lot of big improvements in the props-refactor branch, so hopefully I can get that merged over to master soon for 1.0.

And while UIViewPropertyAnimator introduced by Apple in iOS 10 is an improvement, I still don't like that it's not nearly as flexible or useful as what I've tried to do in bring GSAP's TweenMax/TimelineMax to iOS.

from kinetic.

cupojoe avatar cupojoe commented on September 23, 2024

Yeah. I think the GSAP brought a very powerful animation pattern to a very simple to use API. I've loved it since the Flash days.

edited: Anyhow, here is a snippet where the Timeline onComplete gets called and the onUpdate of the tween doesn't:

let backgroundTween = Tween(target: transitionBackground, from: [.alpha(0)], to: [.alpha(1)], mode: TweenMode.to).duration(1).ease(Easing.swiftOut)

let illustrationTween = Tween(target: transitionIllustration).to(.x(illustrationFrame.origin.x)).duration(1).ease(Easing.outBack)
illustrationTween.onUpdate { (tween) in
    print("update")
}

animator = Timeline(tweens: [backgroundTween, illustrationTween])
animator.onComplete({ (tween) in
    self.replaceBackgroundFor(gradient: GradientBackgroundColor(rawValue: Int(self.goals[self.currentIndex].category))!, in: self.backgroundView)
    tween.setProgress(0)
})

Actually, disregard that. The onUpdate and onComplete both get called. What really happens is that when I set the progress of the animation manually (eg. not by playing the animation) the event's are not called. I realize this is a complete different issue. In fact it's probably the expected behavior, so we should close this issue and maybe I'll open a feature request for that, since it would be useful in scenarios like this, where the animation is controlled by user interaction (pan gesture) and completed when the gesture ends.

from kinetic.

u10int avatar u10int commented on September 23, 2024

Yeah that's probably a good thing to add support for, so I'll add it to my list but may not make it in there until I can wrap up the refactoring branch and merge it in (soon hopefully).

from kinetic.

cupojoe avatar cupojoe commented on September 23, 2024

Makes sense! I'll stay tuned. If I can help in any way... Let me know

from kinetic.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.