unaffix event for Bootstrap affix?
Figured it out myself. This event names are totally confusing. affixed-top.bs.affix
is actually the event when it goes back to being not affixed.
navbar_secondary = $( '.navbar-secondary:first' );
navbar_secondary.affix( {
offset: {
top: function () {
return (this.top = navbar_secondary.offset().top )
}
}
} );
navbar_secondary.on( 'affixed-top.bs.affix', function () {
console.log('unaff');
navbar_secondary.removeClass( 'navbar-fixed-top' ).addClass( 'navbar-not-fixed' );
} );
navbar_secondary.on( 'affix.bs.affix', function () {
console.log('aff');
navbar_secondary.removeClass( 'navbar-not-fixed' ).addClass( 'navbar-fixed-top' );
} );
Summary
affix.bs.affix => before fixed positioning is applied to an element
affixed.bs.affix => after fixed positioning is applied to an element
affix-top.bs.affix => before a top element returns to its original (non-fixed) position
affixed-top.bs.affix => after a top element returns to its original (non-fixed) position
affix-bottom.bs.affix => before a bottom element returns to its original (non-fixed) position
affixed-bottom.bs.affix => after a bottom element returns to its original (non-fixed) position