🦄 mantine-border-animate 3.2.0 — the wedge moves off the main thread

Hey everyone 👋

mantine-border-animate 3.2.0 is out, one day after 3.1.0, and it finishes what that release measured.

What changed.

  • The wedge runs on the GPU. The rotating wedge beam now turns its whole layer with a CSS transform, which the compositor runs, instead of repainting its gradient on the main thread every frame. Twelve wedges went from about 850 ms of main-thread time every 10 seconds to 7.

  • Any shape is covered. A multicolour wedge (colorStops) on a wide button used to leave whole edges bare at some angles. The gradient now covers a border of any shape.

  • An exact catch-up. A border scrolled back into view resumes at the very same point in time, so staggered borders stay in step however often they leave the screen.

  • Nested borders keep their own settings. A border inside a multicolour one no longer paints its parent's gradient or runs on its easing.

The why. The wedge animated the angle of a conic gradient through a registered custom property. It looks smooth, but every frame means a style recalculation and a repaint of the gradient and its blur on the main thread. A transform is the classic fix, with a catch: a layer that rotates must cover the border at every angle, so it is now a square as wide as the border's diagonal, sized with container query units.

The takeaways. Two surprises along the way, both worth knowing in any project:

  • A mask hides paint, not overflow. That big square was invisible, yet it made a phone page scroll sideways. The border now clips its own layer.

  • A GPU-run animation resumes late. After a pause, the compositor picks a transform back up a frame or two after you ask, so the off-screen catch-up drifted 20 to 35 ms on every trip. Putting each animation's original start time back once it is ready made it exact.

One visible change: a wedge with a lot of blur is brighter than before, because its old layer faded into the border.

I'd love to hear from you:

  • Do you check which of your CSS animations run on the main thread, or only notice when something stutters?

  • Have you been bitten by an invisible element widening the page?

Drop a comment below 🙏

📦 npm:

📖 Docs:

💻 GitHub:

4 views

Add a comment

Replies

Be the first to reply

Have a question or a thought to share? Add a comment above to start the conversation.