Commit 00aa816c authored by timel's avatar timel

fix: 动画序列优化

parent d7656ed2
Pipeline #22588 passed with stages
in 9 minutes and 53 seconds
...@@ -3,7 +3,7 @@ import "./index.scss"; ...@@ -3,7 +3,7 @@ import "./index.scss";
import { animated, to, useSpring } from "@react-spring/web"; import { animated, to, useSpring } from "@react-spring/web";
import { Dropdown, type MenuProps } from "antd"; import { Dropdown, type MenuProps } from "antd";
import classnames from "classnames"; import classnames from "classnames";
import React, { type CSSProperties, useEffect, useState } from "react"; import React, { type CSSProperties, useEffect, useState, useRef } from "react";
import { useSnapshot } from "valtio"; import { useSnapshot } from "valtio";
import type { CardMeta } from "@/api"; import type { CardMeta } from "@/api";
...@@ -94,11 +94,11 @@ export const Card: React.FC<{ idx: number }> = React.memo(({ idx }) => { ...@@ -94,11 +94,11 @@ export const Card: React.FC<{ idx: number }> = React.memo(({ idx }) => {
// >>> 动画 >>> // >>> 动画 >>>
/** 动画序列的promise */ /** 动画序列的promise */
let animationQueue: Promise<unknown> = new Promise<void>((rs) => rs()); const animationQueue = useRef(new Promise<void>((rs) => rs()));
const addToAnimation = (p: () => Promise<void>) => const addToAnimation = (p: () => Promise<void>) =>
new Promise((rs) => { new Promise((rs) => {
animationQueue = animationQueue.then(p).then(rs); animationQueue.current = animationQueue.current.then(p).then(rs);
}); });
useEffect(() => { useEffect(() => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment