How is the initial speed of UISpringTimingParameters indicated?

I am trying to perform spring animation in a view that is issued by a user’s gesture and may have a non-zero speed. I'm basically trying to recreate the animation of this WWDC video , where they use it UISpringTimingParameters(dampingRatio:initialVelocity:). However, the documentation seems to contradict itself:

speed

The initial speed and direction of the animation given as a unit vector.

[...]

For example, if the total animation distance is 200 points, and the initial viewing speed is 100 points per second, specify a vector with a value 0.5.

If 0.5is an approximate value, then, apparently, it does not have to be a unit vector. And first of all, it is impossible to code the speed in a single vector.

Unable to rely on the documentation, I tried to connect several different values, but nothing led to even remotely satisfactory results.

How to use this API?

+4
source share
1 answer
Good question.

TL DR: If you are trying to animate something in a position in 2D, you need to animate each coordinate separately, each at the corresponding x / y speed.

, , , , , , , , , , , .

https://github.com/chrisco314/SpringAnimationTest

0

Source: https://habr.com/ru/post/1684860/


All Articles