I've got a simple toggle plus sign that should trigger a div to appear and rotate into an X which can then be clicked to close the div.
Everything works as planned except there is no smooth transition in the rotation of the plus, it just appears already rotated.
If I remove the display:none from the #showbox div and remove $("#showbox").show(), the animation/transition works. It's only if the div is hidden and then shown with .show() that it just rotates without animating.
I'm sure I can think of a workaround, I'm just wondering if anyone can explain why this might be happening
$("#togglebox").click(function() {
$("#showbox").show();
$("#showbox .toggleplus").toggleClass("togglex");
});
#showbox {
background: #000;
width: 500px;
height: 200px;
display: none;
}
.toggleplus {
width: 30px;
height: 30px;
transition: all .5s;
color:#111;
}
#showbox .toggleplus {
color:#FFF;
}
.togglex {
transform: rotate(-46deg);
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="togglebox">
<p>LEARN MORE</p>
<div class="toggleplus">+</div>
</div>
<div id="showbox">
<div class="toggleplus">+</div>
<p>Blah Blah Blah</p>
</div>
+in there for clarification.+is clicked, it will not animate. On subsequent clicks it will.