I'm trying to make the effect of "flip card", when I click, on the front, I want that after n
amount of time the front div
has the property display: none;
with this rule, I detect when the back is active
.card.is-flipped .card__face.card__face--front {
display:none;
}
This is to avoid having interaction with the elements of the front
when you have the back as active. But it looks very abrupt when the display: none
property is applied, so I would like it to be applied after n
number of seconds to apply when it is in the back and the user does not realize this
this is my code:
var card = document.querySelector('.card');
card.addEventListener( 'click', function() {
card.classList.toggle('is-flipped');
});
body { font-family: sans-serif; }
.scene {
width: 200px;
height: 300px;
border: 1px solid #CCC;
margin: 40px 0;
perspective: 600px;
}
.card {
width: 100%;
height: 100%;
transition: transform 1s;
transform-style: preserve-3d;
position: relative;
}
.card.is-flipped {
transform: rotateY(180deg);
}
.card__face {
position: absolute;
width: 100%;
height: 100%;
line-height: 260px;
color: white;
text-align: center;
font-weight: bold;
font-size: 40px;
backface-visibility: hidden;
}
.card__face--front {
background: red;
}
.card__face--back {
background: blue;
transform: rotateY(180deg);
}
.front_button{
background:yellow;
height:200px;
width:100%;
position:absolute;
bottom:0px;
left:0px;
cursor: pointer;
}
.card.is-flipped .card__face.card__face--front {
display:none;
}
this is my real problem, if you click on the yellow square, a click event is executed. when you flip the letter, this event is still running even though I'm in the back. if I put a display none on the front side this does not happen anymore. \ that's why I want to put display none on the front to avoid interaction with the elements of the front part, but I want some trick so that the display step will not be abrupt: none for the front card.