【发布时间】:2014-04-06 20:50:13
【问题描述】:
我想将词缀插件与 bootstrap navbar-fixed-top 类结合起来。到目前为止,我已经让它工作了,然后当我滚动浏览导航栏时,它就会被修复。但是当我向上滚动时,我希望它再次回到静态状态。我从旧的引导程序版本和unaffix 事件中看到了一些我认为的代码。为什么不见了?我可以创建一个吗?或者如何完成我在这里尝试的事情?
navbar_secondary = $( '.navbar-secondary:first' );
navbar_secondary.affix( {
offset: {
top: function () {
return (this.top = navbar_secondary.offset().top )
}
}
} );
navbar_secondary.on( 'affix.bs.affix', function () { // this is actually the wrong event for this. I want this to fire when its *not* affixed
console.log('affix');
navbar_secondary.removeClass( 'navbar-fixed-top' ).addClass( 'navbar-not-fixed' );
} );
navbar_secondary.on( 'affixed.bs.affix', function () {
console.log('affixed');
navbar_secondary.removeClass( 'navbar-not-fixed' ).addClass( 'navbar-fixed-top' );
} );
【问题讨论】:
标签: jquery twitter-bootstrap events twitter-bootstrap-3 jquery-events