Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spring Meng To chaining animations?

Tags:

ios

swift

I don't fully understand the documentation for Meng To's Spring.

https://github.com/MengTo/Spring

The available functions given are

animate()
animateNext { ... }
animateTo()
animateToNext { ... }

and the example for chaining given is :

layer.y = -50
animateToNext {
  layer.animation = "fall"
  layer.animateTo()
}

I don't see anywhere where what these functions do is actually explained. Maybe it's super straight forward and I'm just missing it..

If I wanted to chain together 3 animations of lets just say the layer.animation = "fall" with this, what would an example of that look like and what's the difference between animateNext, animateTo, and animateToNext?

like image 974
user6820041 Avatar asked Feb 06 '17 09:02

user6820041


1 Answers

you are right that's those functions are not will documented so I faced the same questions when I wanted to implement animations with this library.

To chain 3 animations I do like that :

    view.animation = "pop"
    view.duration = 3
    view.delay = 2
    print("1")
    view.animateToNext {
        self.view.animation = "pop"
        self.view.duration = 3
        self.view.delay = 2
        print("2")
        self.view.animateToNext {
            self.view.animation = "pop"
            self.view.duration = 3
            self.view.delay = 2
            self.view.animate()
            print("3")
        }
    }

It seems that animateNext doesn't wait the end of the previous animation to execute the next one, but animateToNext does it.

Hope it helps.

like image 109
Florian Ldt Avatar answered Oct 05 '22 06:10

Florian Ldt