Skip to content

Commit 367c765

Browse files
committed
Support animationSpeed prop and url param
1 parent f013ab1 commit 367c765

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/App.tsx

+5
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,17 @@ function App() {
2424

2525
const isDarkMode = queryParams.get('isDarkMode') === 'true';
2626

27+
const animationSpeed = queryParams.get('animationSpeed')
28+
? parseFloat(queryParams.get('animationSpeed')!)
29+
: undefined;
30+
2731
return (
2832
<div className='min-h-screen flex items-center justify-center p-4'>
2933
<EnumerationDemo
3034
demoType={demoType}
3135
customColors={customColors}
3236
isDarkMode={isDarkMode}
37+
animationSpeed={animationSpeed}
3338
/>
3439
</div>
3540
);

src/components/EnumerationDemo.tsx

+3-1
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,14 @@ interface EnumerationDemoProps extends React.HTMLAttributes<HTMLDivElement> {
5454
demoType?: EnumerationType;
5555
isDarkMode?: boolean;
5656
customColors?: ThemeColors;
57+
animationSpeed?: number;
5758
}
5859

5960
const EnumerationDemo: React.FC<EnumerationDemoProps> = ({
6061
demoType,
6162
isDarkMode = false,
6263
customColors = {},
64+
animationSpeed = 0.18,
6365
className,
6466
...props
6567
}) => {
@@ -94,7 +96,7 @@ const EnumerationDemo: React.FC<EnumerationDemoProps> = ({
9496
const animationRef = useRef<number | null>(null);
9597

9698
const EXPLOSION_DURATION = 500;
97-
const ANIMATION_STEP = 0.18;
99+
const ANIMATION_STEP = animationSpeed;
98100
const FRAME_DURATION = 16;
99101
const MAX_PROGRESS = 150;
100102
const isEven = (n: number): boolean => n % 2 === 0;

0 commit comments

Comments
 (0)