Skip to content

Commit 25e13c1

Browse files
renovate[bot]Slashgearclaude
authored
fix(deps): update dependency motion to v12 (#491)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Antoine CARON <acaron@scaleway.com> Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent eff0136 commit 25e13c1

3 files changed

Lines changed: 72 additions & 81 deletions

File tree

modules/home/Number.tsx

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use client';
22
import React, { useEffect, useRef } from 'react';
3-
import { animate, inView } from 'motion';
3+
import { animate, motion, useInView } from 'motion/react';
44
import { Roboto_Mono } from 'next/font/google';
55

66
const MonospaceFont = Roboto_Mono({
@@ -16,30 +16,32 @@ const counter = (elementRef: HTMLDivElement, start: number, end: number) => {
1616
(progress: number) => {
1717
elementRef.textContent = `${Math.floor(start + progress * range)}`;
1818
},
19-
{ duration, easing: 'ease-out' },
19+
{ duration, ease: 'easeOut' },
2020
);
2121
};
2222

2323
export const Number = ({ value, text }: { value: number; text: string }) => {
24-
const elementRef = useRef(null);
24+
const elementRef = useRef<HTMLLIElement>(null);
2525
const counterRef = useRef<HTMLDivElement>(null);
26+
const isInView = useInView(elementRef, { once: true });
2627

2728
useEffect(() => {
28-
if (elementRef.current) {
29-
inView(elementRef.current, ({ target }) => {
30-
animate(target, { opacity: 1 }, { delay: 0.2, easing: 'ease-out' });
31-
if (counterRef.current) {
32-
counter(counterRef.current, Math.floor(value * 0.6), value);
33-
}
34-
});
29+
if (isInView && counterRef.current) {
30+
counter(counterRef.current, Math.floor(value * 0.6), value);
3531
}
3632
// eslint-disable-next-line react-hooks/exhaustive-deps -- animation should only run on mount
37-
}, []);
33+
}, [isInView]);
3834

3935
return (
40-
<li ref={elementRef} className={MonospaceFont.variable}>
36+
<motion.li
37+
ref={elementRef}
38+
className={MonospaceFont.variable}
39+
initial={{ opacity: 0 }}
40+
animate={isInView ? { opacity: 1 } : {}}
41+
transition={{ delay: 0.2, ease: 'easeOut' }}
42+
>
4143
<div ref={counterRef}>{value}</div>
4244
<div>{text}</div>
43-
</li>
45+
</motion.li>
4446
);
4547
};

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
},
1616
"dependencies": {
1717
"@next/mdx": "16.1.6",
18-
"motion": "^10.18.0",
18+
"motion": "^12.0.0",
1919
"next": "16.1.6",
2020
"normalize.css": "8.0.1",
2121
"react": "19.2.4",

pnpm-lock.yaml

Lines changed: 56 additions & 67 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)