Skip to content

Commit 17f07e8

Browse files
committed
feat(Rotate): update Rotate patterns with new parameters and easing functions
1 parent b2fe293 commit 17f07e8

File tree

2 files changed

+38
-55
lines changed

2 files changed

+38
-55
lines changed

packages/react-components/react-motion-components-preview/stories/src/Rotate/RotateCommonPatterns.stories.tsx

Lines changed: 38 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,28 @@
11
import * as React from 'react';
22
import { makeStyles, tokens, Button, Card, Title3, Body2, Caption1 } from '@fluentui/react-components';
33
import { Rotate } from '@fluentui/react-motion-components-preview';
4+
import { RotateParams } from '../../../library/src/components/Rotate/rotate-types';
5+
6+
type RotatePattern = {
7+
/** Unique identifier for the pattern */
8+
id: string;
9+
/** Display name of the pattern */
10+
name: string;
11+
/** Description of what the pattern does */
12+
description: string;
13+
/** Emoji icon for visual representation */
14+
icon: string;
15+
/** Background color for the demo card */
16+
color: string;
17+
/** The axis of rotation: 'x', 'y', or 'z' - matches Rotate component */
18+
axis: Required<RotateParams['axis']>;
19+
/** The starting rotation angle in degrees - matches Rotate component */
20+
angle: Required<RotateParams['angle']>;
21+
/** Time (ms) for the animation - matches Rotate component */
22+
duration: Required<RotateParams['duration']>;
23+
/** Easing curve for the animation - matches Rotate component */
24+
easing: Required<RotateParams['easing']>;
25+
};
426

527
const useClasses = makeStyles({
628
container: {
@@ -57,72 +79,41 @@ const useClasses = makeStyles({
5779
},
5880
});
5981

60-
const patterns = [
82+
const curveSpringRelaxed = `linear(0.000 0.000%, 0.06073 1.000%, 0.1215 2.000%, 0.1822 3.000%, 0.2429 4.000%, 0.3036 5.000%, 0.3644 6.000%, 0.4251 7.000%, 0.4858 8.000%, 0.5465 9.000%, 0.6073 10.00%, 0.6680 11.00%, 0.7287 12.00%, 0.7895 13.00%, 0.8502 14.00%, 0.9109 15.00%, 0.9716 16.00%, 1.031 17.00%, 1.085 18.00%, 1.131 19.00%, 1.168 20.00%, 1.198 21.00%, 1.220 22.00%, 1.234 23.00%, 1.241 24.00%, 1.242 25.00%, 1.236 26.00%, 1.226 27.00%, 1.211 28.00%, 1.192 29.00%, 1.171 30.00%, 1.148 31.00%, 1.124 32.00%, 1.099 33.00%, 1.074 34.00%, 1.050 35.00%, 1.028 36.00%, 1.007 37.00%, 0.9880 38.00%, 0.9714 39.00%, 0.9572 40.00%, 0.9455 41.00%, 0.9364 42.00%, 0.9298 43.00%, 0.9255 44.00%, 0.9235 45.00%, 0.9236 46.00%, 0.9255 47.00%, 0.9291 48.00%, 0.9339 49.00%, 0.9399 50.00%, 0.9467 51.00%, 0.9541 52.00%, 0.9618 53.00%, 0.9697 54.00%, 0.9774 55.00%, 0.9849 56.00%, 0.9920 57.00%, 0.9986 58.00%, 1.004 59.00%, 1.010 60.00%, 1.014 61.00%, 1.018 62.00%, 1.020 63.00%, 1.022 64.00%, 1.024 65.00%, 1.024 66.00%, 1.024 67.00%, 1.023 68.00%, 1.022 69.00%, 1.021 70.00%, 1.019 71.00%, 1.017 72.00%, 1.014 73.00%, 1.012 74.00%, 1.009 75.00%, 1.007 76.00%, 1.004 77.00%, 1.002 78.00%, 1.000 79.00%, 0.9984 80.00%, 0.9968 81.00%, 0.9954 82.00%, 0.9943 83.00%, 0.9935 84.00%, 0.9929 85.00%, 0.9925 86.00%, 0.9923 87.00%, 0.9924 88.00%, 0.9926 89.00%, 0.9930 90.00%, 0.9935 91.00%, 0.9941 92.00%, 0.9948 93.00%, 0.9956 94.00%, 0.9964 95.00%, 0.9972 96.00%, 0.9979 97.00%, 0.9987 98.00%, 0.9994 99.00%, 1.000 100.0%)`;
83+
84+
const patterns: RotatePattern[] = [
6185
{
6286
id: 'flip-horizontal',
6387
name: 'Horizontal Flip',
6488
description: 'Classic Y-axis rotation',
6589
icon: '↔️',
6690
color: tokens.colorPaletteBlueForeground2,
67-
axis: 'Y' as const,
68-
angle: 180,
69-
easing: 'ease-out',
70-
duration: 600,
91+
axis: 'y',
92+
angle: 90,
93+
easing: curveSpringRelaxed,
94+
duration: 2000,
7195
},
7296
{
7397
id: 'flip-vertical',
7498
name: 'Vertical Flip',
7599
description: 'X-axis rotation',
76100
icon: '↕️',
77101
color: tokens.colorPaletteGreenForeground2,
78-
axis: 'X' as const,
79-
angle: 180,
80-
easing: 'ease-out',
81-
duration: 600,
102+
axis: 'x',
103+
angle: 90,
104+
easing: curveSpringRelaxed,
105+
duration: 2000,
82106
},
83107
{
84108
id: 'spin',
85109
name: 'Spin',
86110
description: 'Z-axis rotation',
87111
icon: '🔄',
88112
color: tokens.colorPaletteRedForeground2,
89-
axis: 'Z' as const,
90-
angle: 360,
91-
easing: 'ease-in-out',
92-
duration: 800,
93-
},
94-
{
95-
id: 'wobble',
96-
name: 'Wobble',
97-
description: 'Gentle X-axis tilt',
98-
icon: '〰️',
99-
color: tokens.colorPaletteYellowForeground2,
100-
axis: 'X' as const,
101-
angle: 15,
102-
easing: 'cubic-bezier(0.25, 0.46, 0.45, 0.94)',
103-
duration: 400,
104-
},
105-
{
106-
id: 'peek',
107-
name: 'Peek',
108-
description: 'Slight Y-axis reveal',
109-
icon: '👀',
110-
color: tokens.colorPaletteTealForeground2,
111-
axis: 'Y' as const,
112-
angle: -15,
113-
easing: 'cubic-bezier(0.25, 0.46, 0.45, 0.94)',
114-
duration: 400,
115-
},
116-
{
117-
id: 'fold',
118-
name: 'Fold',
119-
description: 'Accordion-style fold',
120-
icon: '📄',
121-
color: tokens.colorPaletteDarkOrangeForeground2,
122-
axis: 'X' as const,
123-
angle: -90,
124-
easing: 'cubic-bezier(0.4, 0, 0.2, 1)',
125-
duration: 500,
113+
axis: 'z',
114+
angle: 90,
115+
easing: curveSpringRelaxed,
116+
duration: 2000,
126117
},
127118
];
128119

@@ -213,7 +204,7 @@ CommonPatterns.parameters = {
213204
docs: {
214205
description: {
215206
story:
216-
'A collection of common single-axis rotation patterns that you can use as starting points for your own animations. Each pattern demonstrates rotation around a specific axis (X, Y, or Z) with different easing curves.',
207+
'A collection of common single-axis rotation patterns that you can use as starting points for your own animations. Each pattern demonstrates rotation around a specific axis (X, Y, or Z) with spring-relaxed easing.',
217208
},
218209
},
219210
};

packages/react-components/react-motion-components-preview/stories/src/Rotate/RotateDefault.stories.tsx

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,6 @@ export const Default = (props: React.ComponentProps<typeof Rotate>) => {
6464
const angleMin = -180;
6565
const angleMax = 180;
6666

67-
const curveSpringRelaxed = `linear(
68-
0, 0.009, 0.035 2.1%, 0.141, 0.281 6.7%, 0.723 12.9%, 0.938 16.7%, 1.017,
69-
1.077, 1.121, 1.149 24.3%, 1.159, 1.163, 1.161, 1.154 29.9%, 1.129 32.8%,
70-
1.051 39.6%, 1.017 43.1%, 0.991, 0.977 51%, 0.974 53.8%, 0.975 57.1%,
71-
0.997 69.8%, 1.003 76.9%, 1.004 83.8%, 1
72-
)`;
73-
7467
return (
7568
<div className={classes.container} style={{ perspective }}>
7669
<div className={classes.controls}>
@@ -151,7 +144,6 @@ export const Default = (props: React.ComponentProps<typeof Rotate>) => {
151144
axis={axis}
152145
angle={angle}
153146
duration={duration}
154-
easing={curveSpringRelaxed}
155147
onMotionFinish={() => autoplay && setVisible(v => !v)}
156148
>
157149
<div className={classes.card}>

0 commit comments

Comments
 (0)