I created a simple example here: https://codepen.io/marekKnows_com/pen/LaRPZv
What I would like to do is display the red box 2 seconds AFTER the mouse hovers over the blue box. When the mouse leaves the blue box, I want the red box to disappear immediately.
the HTML code looks like this:
<div id="blueBox">
</div>
<div id="redBox" class="">
</div>
The CSS code:
#blueBox {
  background-color: blue;
  width: 200px;
  height: 50px;
}
#redBox {
  display: none;
  background-color: red;
  width: 200px;
  height: 50px;
  transition: display 0s step-end 2s;
}
#redBox.isVisible {
  transition: display 0s step-end 0s;
  display: block;
}
and the JS code:
const el = document.getElementById( 'blueBox' );
const redEl = document.getElementById( 'redBox' );
el.addEventListener( 'mouseover', () => {
  redBox.classList.add( 'isVisible' );
});
el.addEventListener( 'mouseout', () => {
  redBox.classList.remove( 'isVisible' );
});
What I'm seeing is the red box doesn't wait the 2 seconds before making the redbox appear. Why?
 
    