timdonnelly / Advance

Physics-based animations for iOS, tvOS, and macOS.

Home Page:http://timdonnelly.github.io/Advance/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Spring animation (or any other) won't start after setting target.

TomerAvni opened this issue · comments

HI,
I've been trying for hours to make the animation start, but couldn't. The onChange method, never gets called.
This is the code:

let spring = Spring(initialValue: 0)
spring.onChange = { [weak view] val in
          print("change!") // never gets called.
          view?.frame.origin.y = val
}

spring.target = 500

I've tried debugging the whole thing and the simulation function never turns into .animating (state). I can't figure this out.
Tried calling both view.setNeedsLayout() and view.setNeedsDisplay().

What am I missing?
Thanks.