Motion· 21 of 25

21 of 25

Keep decorative motion independent of busy scripts

For fixed movement between two states, try a CSS transform transition. Once a browser can composite it, a busy main thread can delay script callbacks while the visual transition continues.

Do

Tab indicator: CSS transition
CSS transform transition — browser controls playback

Don’t

Tab indicator: rAF + style writes
rAF transform writes — each update needs a callback

Watch both cards during the three long tasks. The strip samples gaps between main-thread callbacks.

main thread — run it to record

Before you ship

  • Which updates require JavaScript on every frame?
  • Does the indicator actually keep moving on the target device?
  • Can the user activate the destination during the work?

Next

Use release direction and speed for swipe dismissalMotion · 22 of 25J