JS section:
function removeTransition(e) {
if (e.propertyName !== "transform") return;
e.target.classList.remove("playing");
}
keys.forEach(key => key.addEventListener("transitionend", removeTransition));
css section:
.key {
transition: all .07s ease;
}
.playing {
box-shadow: 0 0 1rem -sharpffc600;
transform: scale(1.1);
border-color: -sharpffc600;
}
the rest of the code is mainly to listen for the keydown
event on the keyboard. When a key
is pressed, execute:
key.classList.add("playing");
what I don"t clear is when removeTransition
is called? And after .remove ("playing")
, when will the new style be rendered?
it is found that when the browser processes css, it will terminate the execution of JS first. When is the transitioned
event triggered?