Commit 1a692983 authored by timel's avatar timel

fix: card animation

parent a33e91cc
Pipeline #21997 passed with stages
in 15 minutes and 23 seconds
......@@ -70,26 +70,22 @@ export const Card: FC<{ idx: number }> = React.memo(({ idx }) => {
const [shadowOpacity, setShadowOpacity] = useState(0);
// >>> 动画 >>>
/** 动画序列的promise,当不是undefined,就说明现在这个卡有动画 */
let animation: Promise<unknown> | null = null;
const play = (p: () => Promise<unknown>) => {
if (animation) {
animation = animation.then(p).then(() => (animation = null));
} else {
animation = p().then(() => (animation = null));
}
/** 动画序列的promise */
let animation: Promise<unknown> = new Promise<void>((rs) => rs());
const addToAnimation = (p: () => Promise<unknown>) => {
animation = animation.then(p);
};
eventBus.on(Report.Move, (uuid: string) => {
if (uuid === state.uuid) {
play(() => move(state.zone));
addToAnimation(() => move(state.zone));
}
});
eventBus.on(Report.Chaining, (uuid: string) => {
if (uuid === state.uuid) {
play(() => chaining({ card: state, api }));
addToAnimation(() => chaining({ card: state, api }));
}
});
// <<< 动画 <<<
......
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