Categories
Studio

Jetpack Compose — Earthquake Effect | by Paulo Pereira | Apr, 2021

IEarthquake Mover

Since each property (x, y, rotation, alphaIt is recommended to use because it is the only source of truth. Can be animated As explained Here..

Function “animateTo () of Can be animatedIs a suspend function and must be called from within the coroutine scope. Therefore, to simplify this, both “Moving“When”StopIs marked as a suspend function.

The remaining functions are used to return new offsets, new rotations, and alpha values ​​when moving the container.

All properties are specified with default values ​​at the beginning of the class.

MovingThe function is called on a shake-by-shake basis. Therefore, for each shake, we generate new offsets, rotations, and alphas and animate the properties with these values.

StopThe function is called to animate all properties to their initial state and then stop.

The remaining functions are used to generate random values.

Source

Leave a Reply

Your email address will not be published. Required fields are marked *