Disable copy button until animation completes, fix the fill animation color, change how animations/transitions are disabled
This commit is contained in:
@ -36,22 +36,24 @@
|
||||
container.appendChild(block);
|
||||
|
||||
button.addEventListener("click", async () => {
|
||||
await copyCode(block, header);
|
||||
await copyCode(block, header, button); // Pass the button here
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
async function copyCode(block, header) {
|
||||
async function copyCode(block, header, button) {
|
||||
let code = block.querySelector("code");
|
||||
let text = code.innerText;
|
||||
|
||||
await navigator.clipboard.writeText(text);
|
||||
|
||||
header.classList.add("active");
|
||||
button.setAttribute("disabled", true);
|
||||
|
||||
setTimeout(() => {
|
||||
header.addEventListener("animationend", () => {
|
||||
header.classList.remove("active");
|
||||
}, 800);
|
||||
button.removeAttribute("disabled");
|
||||
}, { once: true });
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
Reference in New Issue
Block a user