Files
AFFiNE-Mirror/blocksuite/affine/components/src/icons/list.ts
T
2025-03-04 10:13:01 +00:00

40 lines
1.2 KiB
TypeScript

export const playCheckAnimation = async (
refElement: Element,
{ left = 0, size = 20 }: { left?: number; size?: number } = {}
) => {
const sparkingEl = document.createElement('div');
sparkingEl.classList.add('affine-check-animation');
if (size < 20) {
console.warn('If the size is less than 20, the animation may be abnormal.');
}
sparkingEl.style.cssText = `
position: absolute;
width: ${size}px;
height: ${size}px;
border-radius: 50%;
`;
sparkingEl.style.left = `${left}px`;
refElement.append(sparkingEl);
await sparkingEl.animate(
[
{
boxShadow:
'0 -18px 0 -8px #1e96eb, 16px -8px 0 -8px #1e96eb, 16px 8px 0 -8px #1e96eb, 0 18px 0 -8px #1e96eb, -16px 8px 0 -8px #1e96eb, -16px -8px 0 -8px #1e96eb',
},
],
{ duration: 240, easing: 'ease', fill: 'forwards' }
).finished;
await sparkingEl.animate(
[
{
boxShadow:
'0 -36px 0 -10px transparent, 32px -16px 0 -10px transparent, 32px 16px 0 -10px transparent, 0 36px 0 -10px transparent, -32px 16px 0 -10px transparent, -32px -16px 0 -10px transparent',
},
],
{ duration: 360, easing: 'ease', fill: 'forwards' }
).finished;
sparkingEl.remove();
};