I'm trying to make this exact transition to reverse. Div Two has a delay so it doesn't become visible before Div One is completely gone. What I want is that if you click on button Two when Div Two is visible, Div Two disappears after that div One appears. So exactly the reverse of the transition.
var One = document.getElementById("one");
var Two = document.getElementById("two");
function actionOne() {
one.style.height = "0px";
two.style.height = "200px";
}
function actionTwo() {
one.style.height = "200px";
two.style.height = "0px";
}
#one {
background: orange;
height: 200px;
overflow: hidden;
transition: 2s;
}
#two {
background: pink;
height:0px;
overflow: hidden;
transition: 2s;
transition-delay: 2s;
}
p {
height: 100%;
}
<button onclick="actionOne()">Button One</button>
<button onclick="actionTwo()">Button Two</button>
<div id="one">
<p>Div One</p>
</div>
<div id="two">
<p>Div Two</p>
</div>