1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
| $(document).on("scroll", onScroll);
var topMenu = $("#headerMenuLieux");
topMenuHeight = topMenu.outerHeight()+15;
//smoothscroll
$('a[href^="#"]').on('click', function (e) {
e.preventDefault();
$(document).off("scroll");
$('a').each(function () {
$(this).removeClass('activeMenu');
})
$(this).addClass('activeMenu');
var target = this.hash,
menu = target;
$target = $(target);
var $scrollTop = $target.offset().top-100;
$('html, body').stop().animate({scrollTop: $scrollTop}, 100, 'swing', function () {
console.log($scrollTop);
window.location.hash = target;
$(document).on("scroll", onScroll);
});
}); |
Partager