Skip to content

Commit d6ebc3d

Browse files
committed
Replace Framer Motion with Motion
1 parent dfdb341 commit d6ebc3d

File tree

3 files changed

+46
-24
lines changed

3 files changed

+46
-24
lines changed

src/components/Animations/FadeLeftToRight.component.tsx

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
// CircleCI doesn't like import { motion } from "framer-motion" here, so we use require
2-
const { motion } = require('framer-motion');
1+
import { motion, Transition } from 'motion/react';
32

43
import type { IAnimateStaggerWithDelayProps } from './types/Animations.types';
54

@@ -21,24 +20,28 @@ const FadeLeftToRight = ({
2120
staggerDelay,
2221
animateNotReverse,
2322
}: IAnimateStaggerWithDelayProps) => {
23+
const visibleTransition: Transition = {
24+
when: 'beforeChildren',
25+
staggerChildren: staggerDelay ? staggerDelay : 0.5,
26+
delay,
27+
ease: 'easeInOut',
28+
staggerDirection: 1,
29+
};
30+
31+
const hiddenTransition: Transition = {
32+
when: 'afterChildren',
33+
staggerChildren: staggerDelay ? staggerDelay : 0.5,
34+
staggerDirection: -1,
35+
};
36+
2437
const FadeLeftToRightVariants = {
2538
visible: {
2639
opacity: 1,
27-
transition: {
28-
when: 'beforeChildren',
29-
staggerChildren: staggerDelay ? staggerDelay : 0.5,
30-
delay,
31-
ease: 'easeInOut',
32-
staggerDirection: 1,
33-
},
40+
transition: visibleTransition,
3441
},
3542
hidden: {
3643
opacity: 0,
37-
transition: {
38-
when: 'afterChildren',
39-
staggerChildren: staggerDelay ? staggerDelay : 0.5,
40-
staggerDirection: -1,
41-
},
44+
transition: hiddenTransition,
4245
},
4346
};
4447
return (

src/components/Animations/FadeLeftToRightItem.component.tsx

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
// CircleCI doesn't like import { motion } from "framer-motion" here, so we use require
2-
const { motion } = require('framer-motion');
1+
import { motion, Transition } from 'motion/react';
32

4-
import type { IAnimateProps } from './types/Animations.types';
3+
import type { IAnimateWithDelayProps } from './types/Animations.types';
54

65
/**
76
* Fade content left to right. Needs to be used with FadeLeftToRight as parent container
@@ -11,14 +10,27 @@ import type { IAnimateProps } from './types/Animations.types';
1110
* @returns {JSX.Element} - Rendered component
1211
*/
1312

14-
const FadeLeftToRightItem = ({ children, cssClass }: IAnimateProps) => {
15-
const FadeLeftToRightItemVariants = {
16-
visible: { opacity: 1, x: 0 },
13+
const FadeLeftToRightItem = ({
14+
children,
15+
cssClass,
16+
}: IAnimateWithDelayProps) => {
17+
const transition: Transition = {
18+
type: 'spring',
19+
duration: 0.5,
20+
stiffness: 110,
21+
};
22+
23+
const fadeLeftToRightItemVariants = {
24+
visible: {
25+
opacity: 1,
26+
x: 0,
27+
transition,
28+
},
1729
hidden: { opacity: 0, x: -20 },
1830
};
1931
return (
2032
<motion.span
21-
variants={FadeLeftToRightItemVariants}
33+
variants={fadeLeftToRightItemVariants}
2234
className={cssClass}
2335
data-testid="fadelefttorightitem"
2436
>

src/components/Animations/FadeUp.component.tsx

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
// CircleCI doesn't like import { motion } from "framer-motion" here, so we use require
2-
const { motion } = require('framer-motion');
1+
import { motion, Transition } from 'motion/react';
32

43
import type { IAnimateWithDelayProps } from './types/Animations.types';
54

@@ -13,14 +12,22 @@ import type { IAnimateWithDelayProps } from './types/Animations.types';
1312
*/
1413

1514
const FadeUp = ({ children, cssClass, delay }: IAnimateWithDelayProps) => {
15+
const transition: Transition = {
16+
delay,
17+
type: 'spring',
18+
duration: 0.5,
19+
stiffness: 110,
20+
};
21+
1622
const fadeUpVariants = {
1723
initial: { opacity: 0, y: 20 },
1824
animate: {
1925
y: 0,
2026
opacity: 1,
21-
transition: { delay, type: 'spring', duration: 0.5, stiffness: 110 },
27+
transition,
2228
},
2329
};
30+
2431
return (
2532
<motion.div
2633
className={cssClass}

0 commit comments

Comments
 (0)