Skip to content

Commit b57349d

Browse files
committed
Reapply "All done!!!"
This reverts commit 92b0333.
1 parent 92b0333 commit b57349d

1 file changed

Lines changed: 114 additions & 102 deletions

File tree

src/components/Animation/4-7-8Animation.tsx

Lines changed: 114 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { motion, useAnimation } from "framer-motion";
2-
import { useEffect } from "react";
1+
import { motion, useAnimate, AnimationPlaybackControlsWithThen} from "framer-motion";
2+
import { useEffect, useState } from "react";
33

44
const Exercise478 = ({isPaused}: {isPaused: boolean}) => {
55
return (
@@ -29,22 +29,36 @@ const BreathingSequence = ({isPaused}: {isPaused: boolean}) => {
2929
};
3030

3131
const Inhale = ({ delay, isPaused }: { delay: number, isPaused: boolean }) => {
32-
const controls =useAnimation();
33-
useEffect(() => {
34-
controls.start({
35-
});
36-
});
37-
38-
useEffect(() => {
39-
if (isPaused) {
40-
controls.stop();
41-
} else {
42-
controls.start();
43-
};
44-
}, [isPaused, controls]);
32+
const [scope, animate] = useAnimate();
33+
const [controls, setControls] = useState<AnimationPlaybackControlsWithThen>()
4534

35+
useEffect(()=>{
36+
const animation = animate(scope.current,{
37+
opacity: [0.3, 0.5, 0.5, 0.3],
38+
scale: [1.5, 3.5, 3.5, 1.5],
39+
}, {
40+
41+
repeat: Infinity,
42+
repeatType: "loop",
43+
duration: 19,
44+
ease: ["easeInOut", "circOut"] ,
45+
times: [0, 0.21, 0.58, 1],
46+
delay,
47+
})
48+
setControls(animation);
49+
}, [animate, delay, scope]);
50+
51+
useEffect(()=>{
52+
if(isPaused){
53+
controls?.pause();
54+
} else {
55+
controls?.play();
56+
}
57+
},[isPaused, controls])
58+
4659
return (
4760
<motion.span
61+
ref={scope}
4862
style={{
4963
x: "50%",
5064
y: "50%",
@@ -55,18 +69,7 @@ const Inhale = ({ delay, isPaused }: { delay: number, isPaused: boolean }) => {
5569
x: "-50%",
5670
y: "-50%",
5771
}}
58-
animate={{
59-
opacity: [0.3, 0.5, 0.5, 0.3],
60-
scale: [1.5, 3.5, 3.5, 1.5],
61-
}}
62-
transition={{
63-
repeat: Infinity,
64-
repeatType: "loop",
65-
duration: 19,
66-
ease: ["easeInOut", "circOut"] ,
67-
times: [0, 0.21, 0.58, 1],
68-
delay,
69-
}}
72+
7073
className=" opacity-1 fixed top-1/2 left-1/2
7174
h-[25vw] w-[25vw] rounded-full
7275
bg-gradient-to-br from-[var(--gradient-1-1)] to-[var(--gradient-1-2)]-500/20
@@ -77,22 +80,36 @@ const Inhale = ({ delay, isPaused }: { delay: number, isPaused: boolean }) => {
7780

7881

7982
const Inhale2 = ({ delay, isPaused }: { delay: number, isPaused: boolean }) => {
80-
const controls =useAnimation();
81-
useEffect(() => {
82-
controls.start({
83-
});
84-
});
85-
86-
useEffect(() => {
87-
if (isPaused) {
88-
controls.stop();
89-
} else {
90-
controls.start();
91-
};
92-
}, [isPaused, controls]);
83+
const [scope, animate] = useAnimate();
84+
const [controls, setControls] = useState<AnimationPlaybackControlsWithThen>()
9385

86+
useEffect(()=>{
87+
const animation = animate(scope.current,{
88+
opacity: [0.3, 0.7, 0.7, 0.5],
89+
scale: [1.5, 3, 3, 1.5],
90+
}, {
91+
92+
repeat: Infinity,
93+
repeatType: "loop",
94+
duration: 19,
95+
ease: ["easeInOut", "circOut"] ,
96+
times: [0, 0.21, 0.58, 1],
97+
delay,
98+
})
99+
setControls(animation);
100+
}, [animate, delay, scope]);
101+
102+
useEffect(()=>{
103+
if(isPaused){
104+
controls?.pause();
105+
} else {
106+
controls?.play();
107+
}
108+
},[isPaused, controls])
109+
94110
return (
95111
<motion.span
112+
ref={scope}
96113
style={{
97114
x: "50%",
98115
y: "50%",
@@ -103,18 +120,7 @@ const Inhale2 = ({ delay, isPaused }: { delay: number, isPaused: boolean }) => {
103120
x: "-50%",
104121
y: "-50%",
105122
}}
106-
animate={{
107-
opacity: [0.3, 0.7, 0.7, 0.5],
108-
scale: [1.5, 3, 3, 1.5],
109-
}}
110-
transition={{
111-
repeat: Infinity,
112-
repeatType: "loop",
113-
duration: 19,
114-
ease: ["easeInOut", "circOut"] ,
115-
times: [0, 0.21, 0.58, 1],
116-
delay,
117-
}}
123+
118124
className=" opacity-1 fixed top-1/2 left-1/2
119125
h-[25vw] w-[25vw] rounded-full
120126
bg-gradient-to-br from-[var(--gradient-1-1)] to-[var(--gradient-1-2)]-500/20
@@ -123,22 +129,36 @@ const Inhale2 = ({ delay, isPaused }: { delay: number, isPaused: boolean }) => {
123129
};
124130

125131
const Inhale3 = ({ delay, isPaused }: { delay: number, isPaused: boolean }) => {
126-
const controls =useAnimation();
127-
useEffect(() => {
128-
controls.start({
129-
});
130-
});
131-
132-
useEffect(() => {
133-
if (isPaused) {
134-
controls.stop();
135-
} else {
136-
controls.start();
137-
};
138-
}, [isPaused, controls]);
132+
const [scope, animate] = useAnimate();
133+
const [controls, setControls] = useState<AnimationPlaybackControlsWithThen>()
139134

135+
useEffect(()=>{
136+
const animation = animate(scope.current,{
137+
opacity: [0.5, 0.9, 0.9, 0.7],
138+
scale: [1.5, 2.5, 2.5, 1.5],
139+
}, {
140+
141+
repeat: Infinity,
142+
repeatType: "loop",
143+
duration: 19,
144+
ease: ["easeInOut", "circOut"] ,
145+
times: [0, 0.21, 0.58, 1],
146+
delay,
147+
})
148+
setControls(animation);
149+
}, [animate, delay, scope]);
150+
151+
useEffect(()=>{
152+
if(isPaused){
153+
controls?.pause();
154+
} else {
155+
controls?.play();
156+
}
157+
},[isPaused, controls])
158+
140159
return (
141160
<motion.span
161+
ref={scope}
142162
style={{
143163
x: "50%",
144164
y: "50%",
@@ -149,41 +169,44 @@ const Inhale3 = ({ delay, isPaused }: { delay: number, isPaused: boolean }) => {
149169
x: "-50%",
150170
y: "-50%",
151171
}}
152-
animate={{
153-
opacity: [0.5, 0.9, 0.9, 0.7],
154-
scale: [1.5, 2.5, 2.5, 1.5],
155-
}}
156-
transition={{
157-
repeat: Infinity,
158-
repeatType: "loop",
159-
duration: 19,
160-
ease: ["easeInOut", "circOut"] ,
161-
times: [0, 0.21, 0.58, 1],
162-
delay,
163-
}}
172+
164173
className=" opacity-1 fixed top-1/2 left-1/2
165174
h-[25vw] w-[25vw] rounded-full
166175
bg-gradient-to-br from-[var(--gradient-1-1)] to-[var(--gradient-1-2)]-500/20
167176
shadow-m [#ffcec5]-500/20 overflow-auto"/>
168177
);
169178
};
170179
const Inhale4 = ({ delay, isPaused }: { delay: number, isPaused: boolean }) => {
171-
const controls =useAnimation();
172-
useEffect(() => {
173-
controls.start({
174-
});
175-
});
176-
177-
useEffect(() => {
178-
if (isPaused) {
179-
controls.stop();
180-
} else {
181-
controls.subscribe();
182-
};
183-
}, [isPaused, controls]);
180+
const [scope, animate] = useAnimate();
181+
const [controls, setControls] = useState<AnimationPlaybackControlsWithThen>()
184182

183+
useEffect(()=>{
184+
const animation = animate(scope.current,{
185+
opacity: [0.3, 0.0, 0.0, 0.1],
186+
scale: [1.5, 3.7, 3.5, 1.5],
187+
}, {
188+
189+
repeat: Infinity,
190+
repeatType: "loop",
191+
duration: 19,
192+
ease: ["easeInOut", "circOut"] ,
193+
times: [0, 0.21, 0.58, 1],
194+
delay,
195+
})
196+
setControls(animation);
197+
}, [animate, delay, scope]);
198+
199+
useEffect(()=>{
200+
if(isPaused){
201+
controls?.pause();
202+
} else {
203+
controls?.play();
204+
}
205+
},[isPaused, controls])
206+
185207
return (
186208
<motion.span
209+
ref={scope}
187210
style={{
188211
x: "50%",
189212
y: "50%",
@@ -194,18 +217,7 @@ const Inhale4 = ({ delay, isPaused }: { delay: number, isPaused: boolean }) => {
194217
x: "-50%",
195218
y: "-50%",
196219
}}
197-
animate={{
198-
opacity: [0.3, 0.0, 0.0, 0.1],
199-
scale: [1.5, 3.7, 3.5, 1.5],
200-
}}
201-
transition={{
202-
repeat: Infinity,
203-
repeatType: "loop",
204-
duration: 19,
205-
ease: ["easeInOut", "circOut"] ,
206-
times: [0, 0.21, 0.58, 1],
207-
delay,
208-
}}
220+
209221
className=" opacity-1 fixed top-1/2 left-1/2
210222
h-[25vw] w-[25vw] rounded-full
211223
bg-gradient-to-br from-[var(--gradient-1-1)] to-[var(--gradient-1-2)]-500/20

0 commit comments

Comments
 (0)