I have no idea why it's not working.
After toggleClass is executed, if the CSS value equals "-84%" then hide();
$(".rwd-sec").click(function() {
$(".rwd-main").toggleClass("is-active");
if ($(".rwd-main").css("right") == "-84%") {
$(".rwd-main").hide();
}
})
.rwd-main {
right: -84%;
}
.rwd-main.is-active {
right: 0;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="rwd-main">
<div class="rwd-sec"></div>
</div>