@@ -24,32 +24,41 @@ onMounted(async () => {
24
24
const nuxtWordPosition = document .querySelector (' #nuxt' )?.getBoundingClientRect ()
25
25
const initialScrollX = window .scrollX
26
26
const initialScrollY = window .scrollY
27
+
27
28
if (figmaWordPosition && nuxtWordPosition ) {
28
- animate (' #cursor1' , { left: Math .round (Math .random () * window .outerWidth ), top: Math .round (Math .random () * window .outerHeight ) }, { duration: 0.1 })
29
- .then (() => animate (' #cursor1' , { opacity: 1 }, { duration: 0.3 }))
30
- .then (() => {
31
- return animate (' #cursor1' , {
32
- left: Math .round (figmaWordPosition .left + initialScrollX + figmaWordPosition .width / 2 ),
33
- top: Math .round (figmaWordPosition .top + initialScrollY - figmaWordPosition .height / 4 )
34
- }, { duration: 1.5 , delay: 0.2 , ease: ' easeInOut' })
35
- })
36
- .then (() => animate (' #cursor1' , { scale: 0.8 }, { duration: 0.1 , ease: ' easeOut' }))
37
- .then (() => animate (' #cursor1' , { scale: 1 }, { duration: 0.1 , ease: ' easeOut' }))
38
- .then (() => animate (' #figma' , { color: ' var(--ui-info)' }, { duration: 0.3 , ease: ' easeOut' }))
39
- .then (() => animate (' #cursor1' , { left: Math .round (figmaWordPosition .left + initialScrollX + figmaWordPosition .width ), top: Math .round (figmaWordPosition .top + initialScrollY ) }, { duration: 0.6 , ease: ' easeInOut' }))
29
+ const cursor1Sequence = async () => {
30
+ await animate (' #cursor1' , { left: Math .round (Math .random () * window .outerWidth ), top: Math .round (Math .random () * window .outerHeight ) }, { duration: 0.1 }).finished
31
+ await animate (' #cursor1' , { opacity: 1 }, { duration: 0.3 }).finished
32
+ await animate (' #cursor1' , {
33
+ left: Math .round (figmaWordPosition .left + initialScrollX + figmaWordPosition .width / 2 ),
34
+ top: Math .round (figmaWordPosition .top + initialScrollY - figmaWordPosition .height / 4 )
35
+ }, { duration: 1.5 , delay: 0.2 , ease: ' easeInOut' }).finished
36
+ await animate (' #cursor1' , { scale: 0.8 }, { duration: 0.1 , ease: ' easeOut' }).finished
37
+ await animate (' #cursor1' , { scale: 1 }, { duration: 0.1 , ease: ' easeOut' }).finished
38
+ await animate (' #figma' , { color: ' var(--ui-info)' }, { duration: 0.3 , ease: ' easeOut' }).finished
39
+ await animate (' #cursor1' , {
40
+ left: Math .round (figmaWordPosition .left + initialScrollX + figmaWordPosition .width ),
41
+ top: Math .round (figmaWordPosition .top + initialScrollY )
42
+ }, { duration: 0.6 , ease: ' easeInOut' }).finished
43
+ }
44
+
45
+ const cursor2Sequence = async () => {
46
+ await animate (' #cursor2' , { left: Math .round (Math .random () * window .outerWidth ), top: Math .round (Math .random () * window .outerHeight ) }, { duration: 0.1 , delay: 0.6 }).finished
47
+ await animate (' #cursor2' , { opacity: 1 }, { duration: 0.3 }).finished
48
+ await animate (' #cursor2' , {
49
+ left: Math .round (nuxtWordPosition .left + initialScrollX + nuxtWordPosition .width / 2 ),
50
+ top: Math .round (nuxtWordPosition .top + initialScrollY - nuxtWordPosition .height / 4 )
51
+ }, { duration: 1.5 , delay: 0.2 , ease: ' easeInOut' }).finished
52
+ await animate (' #cursor2' , { scale: 0.8 }, { duration: 0.1 , ease: ' easeOut' }).finished
53
+ await animate (' #cursor2' , { scale: 1 }, { duration: 0.1 , ease: ' easeOut' }).finished
54
+ await animate (' #nuxt' , { color: ' var(--ui-success)' }, { duration: 0.3 , ease: ' easeOut' }).finished
55
+ await animate (' #cursor2' , {
56
+ left: Math .round (nuxtWordPosition .left + initialScrollX + nuxtWordPosition .width ),
57
+ top: Math .round (nuxtWordPosition .top + initialScrollY )
58
+ }, { duration: 0.6 , ease: ' easeInOut' }).finished
59
+ }
40
60
41
- animate (' #cursor2' , { left: Math .round (Math .random () * window .outerWidth ), top: Math .round (Math .random () * window .outerHeight ) }, { duration: 0.1 , delay: 0.6 })
42
- .then (() => animate (' #cursor2' , { opacity: 1 }, { duration: 0.3 }))
43
- .then (() => {
44
- return animate (' #cursor2' , {
45
- left: Math .round (nuxtWordPosition .left + initialScrollX + nuxtWordPosition .width / 2 ),
46
- top: Math .round (nuxtWordPosition .top + initialScrollY - nuxtWordPosition .height / 4 )
47
- }, { duration: 1.5 , delay: 0.2 , ease: ' easeInOut' })
48
- })
49
- .then (() => animate (' #cursor2' , { scale: 0.8 }, { duration: 0.1 , ease: ' easeOut' }))
50
- .then (() => animate (' #cursor2' , { scale: 1 }, { duration: 0.1 , ease: ' easeOut' }))
51
- .then (() => animate (' #nuxt' , { color: ' var(--ui-success)' }, { duration: 0.3 , ease: ' easeOut' }))
52
- .then (() => animate (' #cursor2' , { left: Math .round (nuxtWordPosition .left + initialScrollX + nuxtWordPosition .width ), top: Math .round (nuxtWordPosition .top + initialScrollY ) }, { duration: 0.6 , ease: ' easeInOut' }))
61
+ await Promise .all ([cursor1Sequence (), cursor2Sequence ()])
53
62
}
54
63
})
55
64
</script >
0 commit comments