Skip to content

Commit 5cacc1c

Browse files
gggritsopriscilawebdev
authored andcommitted
fix(dashboards): Improve performance of Widget Builder animations (#102427)
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.
1 parent ba223ca commit 5cacc1c

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

static/app/components/slideOverPanel.tsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,20 @@ import {motion, type Transition} from 'framer-motion';
66

77
import {space} from 'sentry/styles/space';
88

9-
const PANEL_WIDTH = '50vw';
9+
const RIGHT_SIDE_PANEL_WIDTH = '50vw';
1010
const LEFT_SIDE_PANEL_WIDTH = '40vw';
1111
const PANEL_HEIGHT = '50vh';
1212

1313
const OPEN_STYLES = {
14-
bottom: {opacity: 1, x: 0, y: 0},
15-
right: {opacity: 1, x: 0, y: 0},
16-
left: {opacity: 1, x: 0, y: 0},
14+
bottom: {transform: 'translateX(0) translateY(0)', opacity: 1},
15+
right: {transform: 'translateX(0) translateY(0)', opacity: 1},
16+
left: {transform: 'translateX(0) translateY(0)', opacity: 1},
1717
};
1818

1919
const COLLAPSED_STYLES = {
20-
bottom: {opacity: 0, x: 0, y: PANEL_HEIGHT},
21-
right: {opacity: 0, x: PANEL_WIDTH, y: 0},
22-
left: {opacity: 0, x: '-100%', y: 0},
20+
bottom: {transform: `translateX(0) translateY(${PANEL_HEIGHT})`, opacity: 0},
21+
right: {transform: `translateX(${RIGHT_SIDE_PANEL_WIDTH}) translateY(0)`, opacity: 0},
22+
left: {transform: `translateX(-${LEFT_SIDE_PANEL_WIDTH}) translateY(0)`, opacity: 0},
2323
};
2424

2525
type SlideOverPanelProps = {
@@ -130,7 +130,7 @@ const _SlideOverPanel = styled(motion.div, {
130130
? css`
131131
position: fixed;
132132
133-
width: ${p.panelWidth ?? PANEL_WIDTH};
133+
width: ${p.panelWidth ?? RIGHT_SIDE_PANEL_WIDTH};
134134
height: 100%;
135135
136136
top: 0;

static/app/views/dashboards/widgetBuilder/components/newWidgetBuilder.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -323,9 +323,9 @@ export function WidgetPreviewContainer({
323323
};
324324

325325
const animatedProps: MotionNodeAnimationOptions = {
326-
initial: {opacity: 0, x: '100%', y: 0},
327-
animate: {opacity: 1, x: 0, y: 0},
328-
exit: {opacity: 0, x: '100%', y: 0},
326+
initial: {opacity: 0, transform: 'translateX(100%) translateY(0)'},
327+
animate: {opacity: 1, transform: 'translateX(0) translateY(0)'},
328+
exit: {opacity: 0, transform: 'translateX(100%) translateY(0)'},
329329
transition: animationTransitionSettings,
330330
};
331331

0 commit comments

Comments
 (0)