1
1
<script lang="ts">
2
- import gsap from ' gsap'
3
-
4
2
import idle from ' ../../../assets/img/character/idle.webp'
5
3
import idleColor from ' ../../../assets/img/character/idle-color.webp'
6
4
import idleOutline from ' ../../../assets/img/character/idle-outline.webp'
@@ -13,6 +11,7 @@ import profi from '../../../assets/img/character/profi.webp'
13
11
import profiColor from ' ../../../assets/img/character/profi-color.webp'
14
12
import profiOutline from ' ../../../assets/img/character/profi-outline.webp'
15
13
import profiOutlineColor from ' ../../../assets/img/character/profi-outline-color.webp'
14
+ import type { CSSProperties } from ' vue'
16
15
17
16
export type CharacterPose = ' idle' | ' action' | ' profi'
18
17
@@ -58,44 +57,19 @@ function getAsset(pose: CharacterPose) {
58
57
]
59
58
}
60
59
61
- let initialSvgPath: ReturnType <typeof resolveComponent >
62
60
const useHref = ref (` #${props .pose }-shape ` )
63
-
64
- switch (props .pose ) {
65
- case ' idle' :
66
- initialSvgPath = resolveComponent (' DCharacterShapeIdle' )
67
- break
68
- case ' profi' :
69
- initialSvgPath = resolveComponent (' DCharacterShapeProfi' )
70
- break
71
- case ' action' :
72
- initialSvgPath = resolveComponent (' DCharacterShapeAction' )
73
- break
74
- }
75
-
76
- const shapeToAnimate = ref <ComponentPublicInstance | null >(null )
77
- const shapeIdle = ref <ComponentPublicInstance | null >(null )
78
- const shapeAction = ref <ComponentPublicInstance | null >(null )
79
- const shapeProfi = ref <ComponentPublicInstance | null >(null )
61
+ const useStyle = reactive <CSSProperties >({})
80
62
81
63
watch (
82
64
() => props .pose ,
83
- (newPose , oldPose ) => {
65
+ async (newPose , oldPose ) => {
84
66
if (props .noShape ) return
85
- const poseShapeMap: Record <CharacterPose , SVGPathElement > = {
86
- idle: shapeIdle .value ?.$el ,
87
- action: shapeAction .value ?.$el ,
88
- profi: shapeProfi .value ?.$el
89
- }
90
- if (isMorphSVGPluginInstalled ()) {
91
- gsap .fromTo (
92
- shapeToAnimate .value ?.$el ,
93
- { morphSVG: poseShapeMap [oldPose ] },
94
- { morphSVG: poseShapeMap [newPose ], duration: 0.2 }
95
- )
96
- } else {
97
- useHref .value = ` #${newPose }-shape `
98
- }
67
+ useStyle .transform = ' scale(0.5)'
68
+ useStyle .filter = ' blur(10px)'
69
+ await new Promise (resolve => setTimeout (resolve , 150 ))
70
+ useHref .value = ` #${newPose }-shape `
71
+ useStyle .transform = undefined
72
+ useStyle .filter = undefined
99
73
}
100
74
)
101
75
</script >
@@ -105,21 +79,17 @@ watch(
105
79
<div class =" relative isolate w-full h-full" >
106
80
<svg viewBox =" 0 0 1024 1024" xmlns =" http://www.w3.org/2000/svg" >
107
81
<defs v-if =" !noShape" >
108
- <DCharacterShapeIdle id =" idle-shape" ref = " shapeIdle " />
109
- <DCharacterShapeAction id =" action-shape" ref = " shapeAction " />
110
- <DCharacterShapeProfi id =" profi-shape" ref = " shapeProfi " />
82
+ <DCharacterShapeIdle id =" idle-shape" />
83
+ <DCharacterShapeAction id =" action-shape" />
84
+ <DCharacterShapeProfi id =" profi-shape" />
111
85
</defs >
112
86
<g v-if =" !noShape" >
113
- <component
114
- :is =" initialSvgPath"
115
- v-show =" isMorphSVGPluginInstalled()"
116
- ref =" shapeToAnimate"
117
- :class =" shapeClass"
118
- />
119
87
<use
120
- v-show =" !isMorphSVGPluginInstalled()"
88
+ class =" transition-all"
89
+ :style =" useStyle"
121
90
:class =" shapeClass"
122
91
:href =" useHref"
92
+ transform-origin =" 512 512"
123
93
/>
124
94
</g >
125
95
</svg >
0 commit comments