I have site where I want \'sub navigation\'. So when you scroll to section, its tool bar will affix below the main toolbar. I have this working, but I can\'t change the top offs
I figured it out. Instead of dynamically updating the offset, I changed the offset value to a function:
$(function () {
$('.sec-nav').addClass("affix-top").each(function (){
var $self = $(this);
var offsetFn = function () {
var $p = $self.closest('.sec');
var $$ = $p.prevAll('.sec');
var h = 0;
$$.each(function () { h+=$(this).outerHeight();});
return h;
}
$self.affix({offset: {top: offsetFn}});
});
});
Now when a section changes due to dom manipulation or window re-size, the offset is automaticly changed due to the functions return value changing.