|
1 | 1 | <script setup lang="ts">
|
2 | 2 | useHead({
|
3 |
| - titleTemplate: '%s ← Cedrouseroll Omondi', |
| 3 | + titleTemplate: "%s ← Cedrouseroll Omondi", |
4 | 4 | bodyAttrs: {
|
5 |
| - class: 'relative font-space text-slate-400 leading-relaxed bg-[#002937] selection:text-teal-900 selection:bg-teal-300' |
6 |
| - } |
7 |
| -}) |
| 5 | + class: |
| 6 | + "relative font-space text-slate-400 leading-relaxed bg-[#002937] selection:text-teal-900 selection:bg-teal-300", |
| 7 | + }, |
| 8 | +}); |
8 | 9 |
|
9 |
| -import { gsap } from 'gsap'; |
10 |
| -import { CSSProperties } from 'nuxt/dist/app/compat/capi'; |
| 10 | +import { gsap } from "gsap"; |
| 11 | +// import { CSSProperties } from 'nuxt/dist/app/compat/capi'; |
| 12 | +import type { CSSProperties } from "vue"; |
11 | 13 |
|
12 |
| -const cursorInnerRef = ref() |
13 |
| -const cursorOuterRef = ref() |
| 14 | +const cursorInnerRef = ref(); |
| 15 | +const cursorOuterRef = ref(); |
14 | 16 |
|
15 |
| -const { x, y } = usePointer() |
16 |
| -const isLeft = usePageLeave() |
| 17 | +const { x, y } = usePointer(); |
| 18 | +const isLeft = usePageLeave(); |
17 | 19 |
|
18 | 20 | // hide custom cursor when mouse leaves page
|
19 | 21 | const cursorStyle = computed((): CSSProperties => {
|
20 | 22 | return {
|
21 |
| - 'opacity': isLeft.value ? 0 : 1 |
22 |
| - } |
23 |
| -}) |
| 23 | + opacity: isLeft.value ? 0 : 1, |
| 24 | + }; |
| 25 | +}); |
24 | 26 |
|
25 | 27 | function updateCursor() {
|
26 |
| - console.log('animating mouse') |
| 28 | + console.log("animating mouse"); |
27 | 29 | gsap.set(cursorInnerRef.value, {
|
28 | 30 | left: x.value,
|
29 | 31 | top: y.value,
|
30 |
| - }) |
| 32 | + }); |
31 | 33 |
|
32 | 34 | gsap.to(cursorOuterRef.value, {
|
33 | 35 | duration: 0.2,
|
34 | 36 | x: x.value,
|
35 | 37 | y: y.value,
|
36 | 38 | });
|
37 |
| -
|
38 | 39 | }
|
39 | 40 |
|
40 |
| -
|
41 | 41 | onMounted(() => {
|
42 | 42 | // requestAnimationFrame(updateCursor)
|
43 |
| - useEventListener('mousemove', updateCursor, document) |
44 |
| -}) |
| 43 | + useEventListener("mousemove", updateCursor, document); |
| 44 | +}); |
45 | 45 | </script>
|
46 | 46 |
|
47 | 47 | <template>
|
48 | 48 | <NuxtLayout>
|
49 | 49 | <div class="cursor hidden md:flex">
|
50 |
| - <div ref="cursorInnerRef" |
| 50 | + <div |
| 51 | + ref="cursorInnerRef" |
51 | 52 | class="cursor--small pointer-events-none select-none fixed z-50 top-0 left-0 w-2 h-2 rounded-full bg-[#36E4DA]"
|
52 |
| - :style="cursorStyle"> |
53 |
| - </div> |
54 |
| - <div ref="cursorOuterRef" |
| 53 | + :style="cursorStyle" |
| 54 | + ></div> |
| 55 | + <div |
| 56 | + ref="cursorOuterRef" |
55 | 57 | class="cursor--large pointer-events-none select-none fixed z-50 top-0 left-0 w-8 h-8 rounded-full border border-solid border-[#36E4DA]"
|
56 |
| - :style="cursorStyle"> |
57 |
| - </div> |
| 58 | + :style="cursorStyle" |
| 59 | + ></div> |
58 | 60 | </div>
|
59 | 61 | <NuxtPage />
|
60 | 62 | <!-- <UNotifications /> -->
|
|
0 commit comments