Skip to content

effects/slide: Use mass-spring-damper model for animation

Vlad Zahorodnii requested to merge work/zzag/slide-spring-animation into master

If you lift fingers but not swipe them enough to switch to another virtual desktop, the slide effect will play an animation to move from the current position in the virtual desktop grid to the current desktop.

However, that animation doesn't feel right, there's something missing. The slide effect uses a TimeLine to animate switching between virtual desktops, it's great if the amount of sliding is constant.

This change makes the slide effect use the mass-spring-damper model to simulate the motion of a spring in order to animate switching between virtual desktops.

The mass-spring-damper equation is integrated using RK4. If the delta interval is not multiple of the integration step precisely, the SpringMotion will perform integration as many times as the integration step fits into the delta. The leftover will be used for LERP between the previous and the next integration results.

With the spring animation, the slide animation feels more natural when you lift fingers. If you switch between virtual desktops without using a gesture, the slide animation should look almost the same as if it were implemented with the TimeLine.

The model is describe here https://en.wikipedia.org/wiki/Mass-spring-damper_model.


Before:

2022-05-04_10-32-33.mkv

After:

2022-05-04_10-30-27.mkv

Edited by Vlad Zahorodnii

Merge request reports