import React, { useEffect, useMemo, useRef, useState } from "react"; import styles from "./index.module.scss"; import classNames from "classnames"; import { envUrl } from "@/utils/env"; import { maoData2, mapData1 } from "./data"; import iconImg1 from "@/assets/img/map/icon1.png"; import iconImg1Ac from "@/assets/img/map/icon1Ac.png"; import iconImg2 from "@/assets/img/map/icon2.png"; import iconImg2Ac from "@/assets/img/map/icon2Ac.png"; type Props = { type: number; }; function A0Map({ type }: Props) { const [videoInd, setVidoeInd] = useState(true); const [moveInd, setMoveInd] = useState(0); // 30个动画帧div const moveDiv = useMemo(() => { const arr = []; for (let i = 0; i <= 30; i++) { arr.push(
); } return arr; }, [moveInd]); const moveTime = useRef(-1); useEffect(() => { if (videoInd) { clearInterval(moveTime.current); let num = 0; moveTime.current = window.setInterval(() => { setMoveInd(num); num++; if (num > 30) { clearInterval(moveTime.current); setVidoeInd(false); } }, 50); } return () => { clearInterval(moveTime.current); }; }, [videoInd]); return (
{/* 开场动画帧 */}
{moveDiv}
{/* 一级地图 */}
{/* 定位大图标 */} {mapData1.map((v) => (
{v.id}
{/* 文字标题 */}
{v.name}
{/* 悬停出来的图片和名称 */}
{v.name}
))} {/* 定位小图标 */} {maoData2.map((v) => (
{/* 文字标题 */}
{v.name}
{/* 悬停出来的图片和名称 */}
{v.name}
))}
); } const MemoA0Map = React.memo(A0Map); export default MemoA0Map;