import { animate } from '@lynx-js/motion'; import { runOnMainThread, useEffect, useMainThreadRef } from '@lynx-js/react'; import type { MainThread } from '@lynx-js/types'; import './styles.css'; export default function Basic() { const animateMTRef = useMainThreadRef | null>( null, ); const boxMTRef = useMainThreadRef(null); function startAnimation() { 'main thread'; if (boxMTRef.current) { animateMTRef.current = animate( boxMTRef.current, { scale: 0.4, rotate: '45deg' }, { ease: 'circInOut', duration: 1, repeat: Number.POSITIVE_INFINITY, repeatType: 'reverse', }, ); } } function endAnimation() { 'main thread'; animateMTRef.current?.stop(); } useEffect(() => { const timeoutId = setTimeout(() => { void runOnMainThread(startAnimation)(); }, 1500); return () => { clearTimeout(timeoutId); void runOnMainThread(endAnimation)(); }; }, []); return ( ); }