Advance icon indicating copy to clipboard operation
Advance copied to clipboard

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

Open TomerAvni opened this issue 3 years ago • 0 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.

TomerAvni avatar Jul 22 '20 03:07 TomerAvni