返回 html-video
graphics.html
1 <template id="graphics-template">
2 <div data-composition-id="graphics" data-width="1920" data-height="1080" data-duration="14">
3 <!-- Moment 1: 47% Stat (1.8s - 4.5s) -->
4 <div id="moment-1" class="moment circle-stat">
5 <div class="stat-content">
6 <div class="stat-text">47%</div>
7 <div class="stat-desc">Need Motion Graphics</div>
8 </div>
9 </div>
10
11 <!-- Moment 2: 62% Stat (4.6s - 8.6s) -->
12 <div id="moment-2" class="moment pill-stat">
13 <div class="stat-text">62%</div>
14 </div>
15
16 <!-- Moment 3: Editing Skills (8.8s - 14s) -->
17 <div id="moment-3" class="moment rect-stat">
18 <div class="icon-shape">
19 <svg viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg">
20 <path
21 d="M20,20 Q50,0 80,20 Q100,50 80,80 Q50,100 20,80 Q0,50 20,20"
22 fill="currentColor"
23 />
24 </svg>
25 </div>
26 <div class="stat-text">Editing Skills</div>
27 </div>
28
29 <style>
30 [data-composition-id="graphics"] {
31 position: relative;
32 width: 1920px;
33 height: 1080px;
34 font-family: "Outfit", sans-serif;
35 color: white;
36 overflow: hidden;
37 }
38
39 [data-composition-id="graphics"] .moment {
40 position: absolute;
41 display: flex;
42 align-items: center;
43 justify-content: center;
44 opacity: 0;
45 /* We'll use GSAP to handle the centering and drift */
46 }
47
48 /* Moment 1: Forest Green Circle */
49 [data-composition-id="graphics"] #moment-1 {
50 width: 500px;
51 height: 500px;
52 background-color: #3b5e3a;
53 border-radius: 50%;
54 left: 1400px;
55 top: 540px;
56 transform: translate(-50%, -50%);
57 }
58
59 [data-composition-id="graphics"] .stat-content {
60 display: flex;
61 flex-direction: column;
62 align-items: center;
63 text-align: center;
64 }
65
66 [data-composition-id="graphics"] .stat-desc {
67 font-size: 36px;
68 font-weight: 400;
69 margin-top: 10px;
70 max-width: 300px;
71 line-height: 1.2;
72 }
73
74 /* Moment 2: Ochre Pill */
75 [data-composition-id="graphics"] #moment-2 {
76 width: 500px;
77 height: 220px;
78 background-color: #cc8832;
79 border-radius: 110px;
80 left: 960px;
81 top: 200px;
82 transform: translate(-50%, -50%);
83 }
84
85 /* Moment 3: Terracotta Rounded Rect */
86 [data-composition-id="graphics"] #moment-3 {
87 width: 550px;
88 height: 180px;
89 background-color: #c45d3e;
90 border-radius: 40px;
91 left: 400px;
92 top: 540px;
93 transform: translate(-50%, -50%);
94 padding: 0 40px;
95 justify-content: center;
96 gap: 30px;
97 }
98
99 [data-composition-id="graphics"] .stat-text {
100 font-size: 80px;
101 font-weight: 700;
102 letter-spacing: -2px;
103 }
104
105 [data-composition-id="graphics"] #moment-3 .stat-text {
106 font-size: 54px;
107 letter-spacing: -1px;
108 }
109
110 [data-composition-id="graphics"] .icon-shape {
111 width: 80px;
112 height: 80px;
113 color: rgba(255, 255, 255, 0.9);
114 }
115
116 [data-composition-id="graphics"] .icon-shape svg {
117 width: 100%;
118 height: 100%;
119 }
120 </style>
121
122 <script src="https://cdn.jsdelivr.net/npm/gsap@3.14.2/dist/gsap.min.js"></script>
123 <script>
124 (function () {
125 const tl = gsap.timeline({ paused: true });
126
127 // Moment 1: 1.8s - 4.5s
128 // Gentle drift into place and settle
129 tl.fromTo(
130 "#moment-1",
131 { opacity: 0, x: "+=40", y: "+=15", scale: 0.8 },
132 { opacity: 1, x: 0, y: 0, scale: 1, duration: 1.2, ease: "back.out(1.7)" },
133 1.8,
134 );
135 // Hold until 4.5s, then fade out
136 tl.to("#moment-1", { opacity: 0, scale: 0.8, duration: 0.3, ease: "power2.in" }, 4.2);
137
138 // Moment 2: 4.6s - 8.6s
139 // Gentle drift into place and settle
140 tl.fromTo(
141 "#moment-2",
142 { opacity: 0, y: "-=40", x: "+=10", scale: 0.8 },
143 { opacity: 1, y: 0, x: 0, scale: 1, duration: 1.2, ease: "back.out(1.7)" },
144 4.6,
145 );
146 // Hold until 8.6s, then fade out
147 tl.to("#moment-2", { opacity: 0, scale: 0.8, duration: 0.3, ease: "power2.in" }, 8.3);
148
149 // Moment 3: 8.8s - 14s
150 // Gentle drift into place and settle
151 tl.fromTo(
152 "#moment-3",
153 { opacity: 0, x: "-=40", y: "-=10", scale: 0.8 },
154 { opacity: 1, x: 0, y: 0, scale: 1, duration: 1.2, ease: "back.out(1.7)" },
155 8.8,
156 );
157 // Hold until end (14s)
158 tl.to("#moment-3", { opacity: 0, duration: 0.5, ease: "power2.in" }, 13.5);
159
160 window.__timelines = window.__timelines || {};
161 window.__timelines["graphics"] = tl;
162 })();
163 </script>
164 </div>
165 </template>
166
166 lines HTML