|
26 | 26 | </div> |
27 | 27 | </div> |
28 | 28 | </div> |
29 | | - <div class="wrapper md:border-none mt-10 md:mt-0"> |
30 | | - <RiveAnimation |
31 | | - :desktop-src="homepageAnimation" |
32 | | - :mobile-src="homepageAnimationMobile" |
33 | | - :desktop-width="1280" |
34 | | - :desktop-height="580" |
35 | | - :mobile-width="253" |
36 | | - :mobile-height="268" |
37 | | - canvas-class="w-full" |
38 | | - /> |
39 | | - </div> |
40 | 29 | </template> |
41 | 30 |
|
42 | | -<script setup lang="ts"> |
43 | | -import RiveAnimation from '@components/shared/RiveAnimation.vue'; |
44 | | -import homepageAnimation from '@local-assets/animations/1280_x_580_vite+_masthead.riv'; |
45 | | -import homepageAnimationMobile from '@local-assets/animations/253_x_268_vite+_masthead_mobile.riv'; |
46 | | -
|
47 | | -const smoothScrollTo = (e: Event, targetId: string) => { |
48 | | - e.preventDefault(); |
49 | | - e.stopPropagation(); |
50 | | -
|
51 | | - const element = document.getElementById(targetId); |
52 | | - if (!element) { |
53 | | - return; |
54 | | - } |
55 | | -
|
56 | | - const elementPosition = element.getBoundingClientRect().top + window.scrollY; |
57 | | - const offsetPosition = elementPosition; |
58 | | -
|
59 | | - // Custom smooth scroll with requestAnimationFrame |
60 | | - const startPosition = window.scrollY; |
61 | | - const distance = offsetPosition - startPosition; |
62 | | - const duration = 800; // ms |
63 | | - let startTime: number | null = null; |
64 | | -
|
65 | | - const animation = (currentTime: number) => { |
66 | | - if (startTime === null) { |
67 | | - startTime = currentTime; |
68 | | - } |
69 | | - const timeElapsed = currentTime - startTime; |
70 | | - const progress = Math.min(timeElapsed / duration, 1); |
71 | | -
|
72 | | - // Easing function (easeInOutCubic) |
73 | | - const ease = |
74 | | - progress < 0.5 ? 4 * progress * progress * progress : 1 - Math.pow(-2 * progress + 2, 3) / 2; |
75 | | -
|
76 | | - window.scrollTo(0, startPosition + distance * ease); |
77 | | -
|
78 | | - if (progress < 1) { |
79 | | - requestAnimationFrame(animation); |
80 | | - } |
81 | | - }; |
82 | | -
|
83 | | - requestAnimationFrame(animation); |
84 | | -}; |
85 | | -</script> |
86 | | - |
87 | 31 | <style scoped> |
88 | 32 | .shine-text { |
89 | 33 | background: linear-gradient( |
|
0 commit comments