Removed flickering of color palette demo

This commit is contained in:
squidfunk 2023-03-24 11:36:30 +01:00
parent 70d1002a1d
commit ab23604fb0
No known key found for this signature in database
GPG Key ID: 5ED40BC4F9C436DF

View File

@ -38,10 +38,14 @@ Click on a tile to change the color scheme:
var buttons = document.querySelectorAll("button[data-md-color-scheme]")
buttons.forEach(function(button) {
button.addEventListener("click", function() {
document.body.setAttribute("data-md-color-switching", "")
var attr = this.getAttribute("data-md-color-scheme")
document.body.setAttribute("data-md-color-scheme", attr)
var name = document.querySelector("#__code_0 code span.l")
name.textContent = attr
setTimeout(function() {
document.body.removeAttribute("data-md-color-switching")
})
})
})
</script>