11<script lang="ts">
2- import gsap from ' gsap'
3-
42import idle from ' ../../../assets/img/character/idle.webp'
53import idleColor from ' ../../../assets/img/character/idle-color.webp'
64import idleOutline from ' ../../../assets/img/character/idle-outline.webp'
@@ -13,6 +11,7 @@ import profi from '../../../assets/img/character/profi.webp'
1311import profiColor from ' ../../../assets/img/character/profi-color.webp'
1412import profiOutline from ' ../../../assets/img/character/profi-outline.webp'
1513import profiOutlineColor from ' ../../../assets/img/character/profi-outline-color.webp'
14+ import type { CSSProperties } from ' vue'
1615
1716export type CharacterPose = ' idle' | ' action' | ' profi'
1817
@@ -58,44 +57,19 @@ function getAsset(pose: CharacterPose) {
5857 ]
5958}
6059
61- let initialSvgPath: ReturnType <typeof resolveComponent >
6260const 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 >({})
8062
8163watch (
8264 () => props .pose ,
83- (newPose , oldPose ) => {
65+ async (newPose , oldPose ) => {
8466 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
9973 }
10074)
10175 </script >
@@ -105,21 +79,17 @@ watch(
10579 <div class =" relative isolate w-full h-full" >
10680 <svg viewBox =" 0 0 1024 1024" xmlns =" http://www.w3.org/2000/svg" >
10781 <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" />
11185 </defs >
11286 <g v-if =" !noShape" >
113- <component
114- :is =" initialSvgPath"
115- v-show =" isMorphSVGPluginInstalled()"
116- ref =" shapeToAnimate"
117- :class =" shapeClass"
118- />
11987 <use
120- v-show =" !isMorphSVGPluginInstalled()"
88+ class =" transition-all"
89+ :style =" useStyle"
12190 :class =" shapeClass"
12291 :href =" useHref"
92+ transform-origin =" 512 512"
12393 />
12494 </g >
12595 </svg >
0 commit comments