I have upvoted your question because I am working hard on this problem ...
$(window).on('click.bs.affix.data-api',
This is an event when we click on the affix navigation bar.
This is unlikely for a manual way to create an affix, and I hope that someone better than me in development can help you ...:
Bootlet: http://jsfiddle.net/52VtD/2662/
Js:
$(window).on('click.bs.affix.data-api', function(){ setTimeout( function(){ $target = $("#myNav li.active a").attr('href'); $target = $( $target ); //alert($target); $top = $target.offset().top - $('.page-header').height(); window.scrollTo( 0 , $top); e.stopPropagtion(); }, 10); });
SetTimeout, because affix does its job until ...
Update after comment:
Bootlet: http://jsfiddle.net/52VtD/2663/
Exposure:
setTimeout( function(){ $target = $("#myNav li.active a").attr('href'); $target = $( $target ); //alert($target); $top = $target.offset().top - $('.page-header').height(); window.scrollTo( 0 , $top); e.stopPropagtion(); $("#myNav li.active a").removeClass('active'); // <--- HERE }, 10);
source share