Skip to content

Conversation

@gggritso
Copy link
Member

@gggritso gggritso commented Oct 30, 2025

EDIT: I removed some unrelated changes!

Change 1: Using transform for animations. According to my profiling, animating x, y, and opacity together in Framer Motion uses requestAnimationFrame! When the main thread is busy (which is very often with the Widget Builder), this causes jittery animations. Yuck. Instead, I'm transitioning transform directly, as per the Framer documentation. This delegates the transition straight to the compositor, which is way better! I applied this change to both the Widget Builder and the whole slideout panel.

Using the motion Design Tokens. Scraps specifies the correct bezier curves and durations that we should use. I added some theme configuration that allows using the tokens in a Framer Motion context, by exporting the raw values. Then I dropped them in.

  1. Is this one of the intended uses for these tokens? Do we need different tokens for large UI animations, like opening panels?
  2. The way I exported the values is a bit gross. What would be good names for these tokens?
  3. motion.snap.slow is way too fast for large panels, like the Widget Builder. Can we get another token, or should I use a custom value?

@linear
Copy link

linear bot commented Oct 30, 2025

@github-actions github-actions bot added the Scope: Frontend Automatically applied to PRs that change frontend components label Oct 30, 2025
`x` and `y` coordinates are animated using `requestAnimationFrame`
This makes it possible to use them in Framer Motion components, which
need numeric values.
More better performance!
@gggritso gggritso force-pushed the georgegritsouk/dain-1051-widget-builder-animation-is-janky branch from 180cdac to 524c51a Compare October 30, 2025 18:29
@gggritso gggritso marked this pull request as ready for review October 30, 2025 19:13
@gggritso gggritso requested a review from a team as a code owner October 30, 2025 19:13
@gggritso gggritso requested a review from a team October 30, 2025 19:13
cursor[bot]

This comment was marked as outdated.

Comment on lines +74 to +75
type: 'tween',
ease: theme.motionControlPoints.enter,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kind of a bummer we went from physics controller moment to a fixed linear bezier motion curve. Will have to play with it, but my experience with simple bezier curves is that it's hard to get it to feel nice

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤷🏻‍♂️ you tell me, I'm opting to use the motion tokens that we have. If that's not appropriate for panels I'm totally fine to move it back, as long as they can run at high FPS in busy situations

@gggritso gggritso changed the title fix(dashboards): Improve Widget Builder animation performance feat(dashboards): Use Motion design tokens for animation Oct 30, 2025
Comment on lines 1176 to +1178
motion: generateMotion(),
motionControlPoints: BEZIER_CONTROL_POINTS,
motionDurations: MOTION_DURATIONS,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could these be merged into theme.motion ? Could be a follow-up but I don’t think we should have too many top-level things on the theme, makes it harder to discover imo. Same as we have all tokens now grouped in theme.tokens

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@TkDodo yes definitely! I'm waiting for #102531 and then I'll work on top of that 👍🏻

gggritso added a commit that referenced this pull request Nov 3, 2025
…02427)

Peeled from #102415. Changes the
Widget Builder (and Slideout Panel) animations to use `transform`. This
forces Framer Motion to use GPU-accelerated animations rather than
`requestAnimationFrame`. This noticeably improves performance when the
main thread is busy (e.g., in the Widget Builder, all the time) and
reduces jitter.
shashjar pushed a commit that referenced this pull request Nov 4, 2025
…02427)

Peeled from #102415. Changes the
Widget Builder (and Slideout Panel) animations to use `transform`. This
forces Framer Motion to use GPU-accelerated animations rather than
`requestAnimationFrame`. This noticeably improves performance when the
main thread is busy (e.g., in the Widget Builder, all the time) and
reduces jitter.
@gggritso
Copy link
Member Author

gggritso commented Nov 5, 2025

This PR's muddied the waters somewhat, I'm going to close it an open up something more sensible.

@gggritso gggritso closed this Nov 5, 2025
priscilawebdev pushed a commit that referenced this pull request Nov 6, 2025
…02427)

Peeled from #102415. Changes the
Widget Builder (and Slideout Panel) animations to use `transform`. This
forces Framer Motion to use GPU-accelerated animations rather than
`requestAnimationFrame`. This noticeably improves performance when the
main thread is busy (e.g., in the Widget Builder, all the time) and
reduces jitter.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Frontend Automatically applied to PRs that change frontend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants