Remove class giving transition effect

Asked

Viewed 123 times

0

Guys I have a class called 'Fixed' with a Transition in it, when I add this class it makes a transaction, the problem is that when I remove this class, it is being removed very roughly, do not know how to proceed to give a transaction effect also in the exit of this class, the class Fixed has a linear transition all of 1 second:

var menu = $('.fixa').offset().top + 10;
var $meuMenu = $('fixa');
$(document).on('scroll', function () {
    if (menu <= $(window).scrollTop()) {
        $('.fixa').addClass('fixed');
    } else {
        $('.fixa').removeClass('fixed');
    }
});
  • 1

    This will depend on the difherence that exists between the element with and without class Fixed. You can work with 2 class, removing one and adding the other simultaneously, one reverting to the other. There is also a tutorial on stackoverflow in English: http://stackoverflow.com/questions/9509002/css-transition-when-class-removed. This also explains well: http://stackoverflow.com/questions/21148876/css3-transition-with-jquery-addclass-and-removeclass

  • I had already thought about adding another class to remove, but I thought I had a way to delete this option, I ended up choosing to create another class even, vlw

  • It’s probably a problem with your CSS. I made this code to test and it works OK. http://codepen.io/fernandosavio/pen/xgEvbz

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.