I upvoted your question because I was working hard to this problem...
$(window).on('click.bs.affix.data-api',
It's the event when we click on the affix navbar.
It unlikely a manual way to make the affix, and I hope someone better than me in development can help you... :
Bootply : 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 do his work before...
Update after comment :
Bootply : http://jsfiddle.net/52VtD/2663/
Extract :
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);