I'm trying to create a design where you click on a box, it'll slide into another view with more content, and when you click the arrow, it'll return.
The problem is this:
$(boxes).one('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend', function() {
boxes.parent().css({
'height' : '0',
'opacity' : '0',
'overflow' : 'hidden'
});
fboxContentCover.css({
'height' : 'auto',
'opacity' : '1',
});
fboxContentCover.removeClass('fadeOutLeft').addClass('animated bounceInRight');
});
$(fboxContentCover).one('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend', function() {
fboxContentCover.css({
'height' : '0',
'opacity' : '0',
'overflow' : 'hidden'
});
$('.fbox').parent().css({
'height' : 'auto',
'opacity' : '1',
});
$('.fbox').removeClass('fadeOutLeft').addClass('animated fadeInRight');
});
When the first one is done, it goes to the second view successfully, however, when you click back, it'll slide into the first view again, but it'll then flash the second view again and then go back to the first view, again.
How can I stop this from happening?
The code and everything is here: https://codepen.io/anon/pen/JNodjO
When adding .toggleClass
instead of .removeClass().addClass()
, the animation completely stops working.