Spaces:
Sleeping
Sleeping
File size: 2,232 Bytes
a72140d | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 | "use client";
import React, { useEffect, useRef, useMemo } from "react";
import { setIntervalOnVisible } from "@/utils/set-timeout-on-visible";
export default function SubtleAsciiAnimation({
className = "",
}: {
className?: string;
}) {
const containerRef = useRef<HTMLDivElement>(null);
// Simple ASCII pattern for subtle animation
const asciiFrames = useMemo(() => [
"ββββββββββββββββ",
"ββββββββββββββββ",
"ββββββββββββββββ",
"ββββββββββββββββ",
"ββββββββββββββββ",
"ββββββββββββββββ",
"ββββββββββββββββ",
"ββββββββββββββββ",
"ββββββββββββββββ",
"ββββββββββββββββ",
"ββββββββββββββββ",
"ββββββββββββββββ",
"ββββββββββββββββ",
"ββββββββββββββββ",
"ββββββββββββββββ",
"ββββββββββββββββ",
"ββββββββββββββββ",
"ββββββββββββββββ",
], []);
useEffect(() => {
let frameIndex = 0;
const animateAscii = () => {
if (containerRef.current) {
containerRef.current.innerHTML = asciiFrames[frameIndex];
frameIndex = (frameIndex + 1) % asciiFrames.length;
}
};
// Initialize first frame
animateAscii();
// Start animation when visible
const cleanup = setIntervalOnVisible({
element: containerRef.current,
callback: animateAscii,
interval: 150, // Slightly slower for subtlety
});
return () => {
cleanup?.();
};
}, [asciiFrames]);
return (
<div
ref={containerRef}
className={`font-mono text-white/20 whitespace-pre select-none ${className}`}
style={{
fontSize: "10px",
lineHeight: "1",
letterSpacing: "0.05em",
}}
/>
);
}
|