fix copy button animation

This commit is contained in:
Cory LaViska
2021-08-12 12:57:13 -04:00
parent f8aff7dcd9
commit b0cf35d264
2 changed files with 5 additions and 3 deletions

View File

@@ -179,7 +179,7 @@
}
.markdown-section .docsify-copy-code-button.copied {
animation: pulse 1s;
animation: pulse 0.75s;
--pulse-color: rgb(var(--sl-color-neutral-500));
}

View File

@@ -202,10 +202,12 @@
// Show pulse when copying
document.addEventListener('click', event => {
const button = event.target.closest('.docsify-copy-code-button');
if (button) {
button.classList.remove('copied');
requestAnimationFrame(() => button.classList.add('copied'));
requestAnimationFrame(() => {
button.addEventListener('animationend', () => button.classList.remove('copied'), { once: true });
button.classList.add('copied');
});
}
});
})();