I have a link on my web page as soon as i click on it i need it to be rotate 180 degrees.
Html that includes link tag with icon down:
When click on it add class collapsed:
If collapsed class add then rotate the .fa-caret-down
in 180 degrees.
$(document).on("click", ".collapse-arrow", function() {
$(this).toggleClass("collapsed");
$("#slide-div").slideToggle(500);
});
.collapsed .fa {
transform: rotate(-180deg);
}
}
.fa {
padding: 5px 8px;
transition: all .2s ease-in-out;
transform: rotate(0);
font-size: 15px;
color: #000;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<a href="#" class="collapse-arrow room-collapse">
<i class="fa fa-caret-down"></i>
</a>
This works fine when the web page has fewer elements. But after page gets more elements this transition takes few seconds (3 seconds). Also slideToggle of #slide-div takes time. But this works fine as soon as i remove this rotate property.
What could be the issue here?