Something went wrong. Try again.
source code of sayemon10.com sayemon10.com
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768<script lang="ts"> import { gsap } from 'gsap'; import { animationStore } from '#lib/animationStore.svelte.js';
let currentTime = $state(''); let timeRef: HTMLSpanElement; let timeline: gsap.core.Timeline | null = null;
// Interval: set up on mount, clear on destroy $effect(() => { const intervalId = setInterval(() => { const today = new Date(); currentTime = today.toLocaleTimeString('en-US', { hour: '2-digit', minute: '2-digit', hour12: true, timeZone: 'Asia/Dhaka' }); }, 1000);
return () => clearInterval(intervalId); });
// Animation: re-run whenever currentTime changes $effect(() => { const time = currentTime;
if (!timeRef || !time) return;
timeline?.kill();
timeline = gsap .timeline() .to(timeRef, { opacity: 0, top: 20, duration: animationStore.normal, ease: 'circ.out' }) .set(timeRef, { top: 0 }) .to(timeRef, { opacity: 0, top: -20, duration: animationStore.normal, ease: 'circ.out' }) .to(timeRef, { opacity: 1, top: 0, duration: animationStore.normal, ease: 'circ.out' });
return () => { timeline?.kill(); }; });</script>
<div class="relative mt-8 h-8 w-24 overflow-hidden"> <span bind:this={timeRef} class="absolute top-0 right-0 bottom-0 left-0 ml-auto w-fit font-normal" > {currentTime} </span></div>