');
$('
').addClass('follower-floating transparent').appendTo('.wrapper-floating');
function updateFollowerPosition() {
var active = $('.link-active');
if (active.length === 0) return;
var width = active.outerWidth();
var scrollTop = $(window).scrollTop();
var left = active.offset().left;
var top = active.offset().top - scrollTop + active.outerHeight() - 3;
$('.follower-floating')
.css({
'width': width + 'px',
'left': left + 'px',
'top': top + 'px'
});
activeLink = active.attr("href");
}
updateFollowerPosition();
setTimeout(function() {
$('.follower-floating')
.removeClass('transparent')
.css({
'opacity': 1
});
}, 500);
$('.wrapper-floating .link-floating').on('mouseenter', function() {
var $this = $(this);
var width = $this.outerWidth();
var scrollTop = $(window).scrollTop();
var left = $this.offset().left;
var top = $this.offset().top - scrollTop + $this.outerHeight() - 3;
$('.follower-floating')
.css({
'width': width + 'px',
'left': left + 'px',
'top': top + 'px',
'opacity': 1
});
$('.link-floating').removeClass('follower-active');
$this.addClass('follower-active');
$('.link-active').removeClass('link-active');
$this.find('.tn-atom').addClass('link-active');
});
$('.wrapper-floating').on('mouseleave', function() {
$('.follower-floating')
.css({
'opacity': 1
});
});
$(window).on('scroll', function() {
updateFollowerPosition();
updateLinkColors();
});
var topMenuHeight = $('.uc-nav-active').outerHeight() + 150;
var menuItems = $(".link-floating a"),
scrollItems = menuItems.map(function(){
var item = $($(this).attr("href"));
if (item.length) { return item; }
});
function updateLinkColors() {
var fromTop = $(window).scrollTop() + topMenuHeight;
var cur = scrollItems.map(function(){
var itemTop = $(this).offset().top;
var itemBottom = itemTop + $(this).outerHeight();
if (itemTop fromTop)
return this;
});
cur = cur[cur.length-1];
var id = cur && cur.length ? cur[0].id : "";
menuItems
.removeClass("link-active")
.filter("[href='#"+id+"']").addClass("link-active");
if (activeLink && id === activeLink.substr(1)) {
updateFollowerPosition();
}
}
$(window).scroll(function(){
updateLinkColors();
});
});
}
});