Skip to content

Commit 685c04d

Browse files
committed
static svg logo scale in animation
1 parent 447d48e commit 685c04d

1 file changed

Lines changed: 32 additions & 17 deletions

File tree

components/svg-hero.server.vue

Lines changed: 32 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,11 @@ const logoStages = [
1212
]
1313
1414
const values = computed(() => logoStages.join(";"))
15+
const easeInOutExpo = "0.87 0 0.13 1"
16+
const easeOutExpo = "0.16, 1, 0.3, 1"
1517
1618
const keySplines = computed(() => {
17-
return Array.from({ length: logoStages.length - 1 }, () => "0.87 0 0.13 1").join(";")
19+
return Array.from({ length: logoStages.length - 1 }, () => easeInOutExpo).join(";")
1820
})
1921
2022
const keyTimes = computed(() => {
@@ -29,6 +31,9 @@ const keyTimes = computed(() => {
2931
const width = 1200
3032
const height = 630
3133
34+
const logoWidth = 312
35+
const logoHeight = 186
36+
3237
const STAR_AMOUNT = 30
3338
const X_SPEED = 0.125
3439
const ROUND_DECIMALS = 2
@@ -44,7 +49,7 @@ const stars = Array.from({ length: STAR_AMOUNT })
4449
begin: 0,
4550
}
4651
47-
star.begin = Math.random() * (star.duration / 3)
52+
star.begin = Math.random() * (star.duration / 4)
4853
4954
if (Math.random() > 0.5) {
5055
star.xSpeed *= -1
@@ -61,13 +66,7 @@ const stars = Array.from({ length: STAR_AMOUNT })
6166
</script>
6267

6368
<template>
64-
<svg
65-
:width="width"
66-
:height="height"
67-
:viewBox="`0 0 ${width} ${height}`"
68-
fill="none"
69-
xmlns="http://www.w3.org/2000/svg"
70-
>
69+
<svg :width="width" :height="height">
7170
<g filter="url(#s)">
7271
<rect x="25" y="25" width="1150" height="580" rx="24" fill="black" />
7372
<g opacity="0.75">
@@ -122,16 +121,32 @@ const stars = Array.from({ length: STAR_AMOUNT })
122121
/>
123122
<rect x="-156" y="-176" width="1512" height="982" fill="url(#p5)" />
124123
</g>
124+
<!-- logo -->
125125
<svg
126-
width="312"
127-
height="186"
128-
:x="width / 2 - 312 / 2"
129-
:y="height / 2 - 186 / 2"
130-
viewBox="0 0 312 186"
131-
fill="none"
132-
xmlns="http://www.w3.org/2000/svg"
126+
:width="logoWidth"
127+
:height="logoHeight"
128+
:x="width / 2 - logoWidth / 2"
129+
:y="height / 2 - logoHeight / 2"
133130
>
134-
<path ref="path" fill="white">
131+
<path
132+
ref="path"
133+
fill="white"
134+
:transform-origin="`${logoWidth / 2} ${logoHeight / 2}`"
135+
>
136+
<!-- animate scale-in -->
137+
<animateTransform
138+
attributeName="transform"
139+
from="0 0"
140+
to="1 1"
141+
begin="0s"
142+
dur="2.5s"
143+
fill="freeze"
144+
type="scale"
145+
calcMode="spline"
146+
:keySplines="easeOutExpo"
147+
keyTimes="0;1"
148+
/>
149+
<!-- animate path -->
135150
<animate
136151
attributeName="d"
137152
begin="250ms"

0 commit comments

Comments
 (0)