Browse Source

Making progress

feat/year-wrapped
Elias Sebbar 2 days ago
parent
commit
61186f1770

+ 12
- 0
vite-wrapped/public/square.svg View File

@@ -0,0 +1,12 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<svg
3
+    id="Calque_1"
4
+    data-name="Calque 1"
5
+    xmlns="http://www.w3.org/2000/svg"
6
+    viewBox="0 0 400 400"
7
+>
8
+    <polygon stroke="white" fill="#00000000"
9
+    stroke-width="1em"
10
+    points="0 0 400 0 400 400 0 400"
11
+    />
12
+</svg>

+ 31
- 2
vite-wrapped/src/App.tsx View File

@@ -2,7 +2,11 @@ import "./App.css";
2 2
 // @deno-types="@types/react"
3 3
 import React, { useEffect, useState } from "react";
4 4
 
5
-import { motion, useMotionValue, useMotionValueEvent } from "framer-motion";
5
+import {
6
+  AnimatePresence,
7
+  motion,
8
+  useMotionValue,
9
+} from "framer-motion";
6 10
 import { useAnimationFrame } from "framer-motion";
7 11
 import Welcome from "./steps/welcome.tsx";
8 12
 import GlobalTop from "./steps/GlobalTop.tsx";
@@ -22,6 +26,22 @@ const steps = [
22 26
   },
23 27
 ];
24 28
 
29
+const enterAnimation = {
30
+  opacity: 0,
31
+  scale: 0,
32
+  transition: {
33
+    duration: 0.25,
34
+  },
35
+};
36
+
37
+const exitAnimation = {
38
+  opacity: 0,
39
+  scale: 0,
40
+  transition: {
41
+    duration: 0.25,
42
+  },
43
+};
44
+
25 45
 function App() {
26 46
   const [currentStep, setCurrentStep] = useState(0);
27 47
   const animationDuration = 10_000;
@@ -56,7 +76,16 @@ function App() {
56 76
             right: "0",
57 77
           }}
58 78
         >
59
-          <CurrentStepContent key={`${currentStep}`} progress={animationProgress} />
79
+          <AnimatePresence>
80
+            <motion.span
81
+              key={`${currentStep}`}
82
+              initial={enterAnimation}
83
+              exit={exitAnimation}
84
+              animate={{ opacity: 1, scale: 1 }}
85
+            >
86
+              <CurrentStepContent progress={animationProgress} />
87
+            </motion.span>
88
+          </AnimatePresence>
60 89
           {/*  <Welcome progress={animationProgress} /> */}
61 90
         </div>
62 91
         <div style={{ zIndex: 100, fontSize: "5px" }}>

+ 4
- 1
vite-wrapped/src/components/mask/Masked.tsx View File

@@ -1,6 +1,6 @@
1 1
 import React from "react";
2 2
 
3
-type Mask = "Star";
3
+type Mask = "Star" | "Square";
4 4
 
5 5
 function Masked({
6 6
   children,
@@ -17,6 +17,9 @@ function Masked({
17 17
     if (mask === "Star") {
18 18
       setMaskUrl("/star.svg");
19 19
     }
20
+    if (mask === "Square") {
21
+      setMaskUrl("/square.svg");
22
+    }
20 23
   }, [mask]);
21 24
 
22 25
   return (

+ 1
- 1
vite-wrapped/src/steps/GlobalTop.tsx View File

@@ -15,7 +15,7 @@ const leftSideVariants: Variants = {
15 15
       repeat: 0,
16 16
       type: "spring",
17 17
       ease: "easeInOut",
18
-      delay: 0.5 + props.delay,
18
+      delay: 1.5 + props.delay,
19 19
     },
20 20
   }),
21 21
   "2": (props: VariantProps) => ({

+ 62
- 24
vite-wrapped/src/steps/welcome.tsx View File

@@ -7,6 +7,10 @@ type VariantProps = {
7 7
   delay: number;
8 8
 };
9 9
 
10
+type NudgedVariantProps = VariantProps & {
11
+    nudge: number;
12
+    };
13
+
10 14
 const starVariants: Variants = {
11 15
   "1": (props: VariantProps) => ({
12 16
     rotate: 360,
@@ -14,21 +18,21 @@ const starVariants: Variants = {
14 18
     transition: {
15 19
       duration: 2,
16 20
       repeat: 0,
17
-      delay: props.delay,
21
+      delay: 1.5 + props.delay,
18 22
     },
19 23
   }),
20 24
   "2": (props: VariantProps) => ({
21
-    scale: 3,
25
+    scale: 10,
22 26
     x: props.delay,
23 27
     rotate: props.delay + 365 * 2,
24 28
     transition: {
25
-      duration: 1,
29
+      duration: 1.5,
26 30
       repeat: 0,
27 31
       delay: props.delay,
28 32
     },
29 33
   }),
30 34
   "3": (props: VariantProps) => ({
31
-    scale: 3,
35
+    scale: 10,
32 36
     rotate: props.delay + 365 * 3,
33 37
     transition: {
34 38
       duration: 6,
@@ -39,31 +43,38 @@ const starVariants: Variants = {
39 43
   }),
40 44
 };
41 45
 
42
-const textAreaVariants: Variants = {
43
-  "1": {
44
-    opacity: 1,
45
-    width: "80%",
46
-    height: "80%",
46
+const letterVariants: Variants = {
47
+  "1": (props: NudgedVariantProps) => ({
48
+    rotate: (360 - 45) * props.nudge,
49
+    scale: 4,
47 50
     transition: {
48
-      duration: 0.5,
51
+      duration: 2,
52
+      ease: 'easeOut',
53
+      delay: 1.5 + props.delay,
49 54
     },
50
-  },
51
-  "2": {
52
-    opacity: 1,
53
-    width: "80%",
54
-    height: "80%",
55
+  }),
56
+  "2": (props: NudgedVariantProps) => ({
57
+    rotate: 360 * props.nudge,
58
+    x: -props.nudge * 19,
59
+    z:0.1,
60
+    scale: 4,
55 61
     transition: {
56
-      duration: 1.5,
62
+      duration: 2,
63
+      ease: 'easeInOut',
64
+      delay: props.delay,
57 65
     },
58
-  },
59
-  "3": {
60
-    opacity: 1,
61
-    width: "80%",
62
-    height: "80%",
66
+  }),
67
+  "3": (props: NudgedVariantProps) => ({
68
+    rotate: 361 * props.nudge,
69
+    x: -props.nudge * 20,
70
+    scale: 4,
71
+    z:0.2,
63 72
     transition: {
64
-      duration: 1,
73
+      duration: 6,
74
+      ease: 'easeInOut',
75
+      delay: props.delay,
65 76
     },
66
-  },
77
+  }),
67 78
 };
68 79
 
69 80
 type RunningAnimations = {
@@ -113,11 +124,34 @@ function Welcome({ progress }: StepProps) {
113 124
           onAnimationComplete={() => animationComplete(starVariant)}
114 125
         >
115 126
           <div style={{ width: "800px", height: "800px" }}>
116
-            <Masked mask="Star" style={starStyle} />
127
+            <Masked mask="Square" style={starStyle} />
117 128
           </div>
118 129
         </motion.div>
119 130
       ))}
120 131
 
132
+      <motion.div
133
+        style={{
134
+          display: "flex",
135
+          position: "absolute",
136
+        }}
137
+      >
138
+        <motion.div
139
+          variants={letterVariants}
140
+          animate={starVariant}
141
+          custom={{ delay: 0, nudge: 1 }}
142
+          style={letterStyle}
143
+        >
144
+          2
145
+        </motion.div>
146
+        <motion.div
147
+          variants={letterVariants}
148
+          animate={starVariant}
149
+          custom={{ delay: 0.1, nudge: -1 }}
150
+          style={letterStyle}
151
+        >
152
+          4
153
+        </motion.div>
154
+      </motion.div>
121 155
     </div>
122 156
   );
123 157
 }
@@ -148,5 +182,9 @@ const starStyle = {
148 182
     "radial-gradient(circle at center center,rgb(95, 247, 68),rgb(247, 255, 19)), repeating-radial-gradient(circle at center center,rgb(0, 255, 140),rgb(77, 247, 68), 10px, transparent 90px, transparent 10px)",
149 183
 };
150 184
 
185
+const letterStyle = {
186
+  scale: 0,
187
+  fontSize: "3em"
188
+};
151 189
 
152 190
 export default Welcome;

Loading…
Cancel
Save