sans smooth scroll pour le premier retour des ancres sans va-et-vient

This commit is contained in:
chankalan 2021-01-28 10:45:02 +01:00
parent ade00e73f3
commit fd98f66477
1 changed files with 20 additions and 20 deletions

View File

@ -55,26 +55,26 @@ $(function() {
}); });
// smooth scroll // smooth scroll
$('a[href^="#"], .js-scrollTo').on('click', function(e) { // $('a[href^="#"], .js-scrollTo').on('click', function(e) {
if($(this).hasClass('js-noscroll')) { // if($(this).hasClass('js-noscroll')) {
return; // return;
} // }
var hash = this.hash; // var hash = this.hash;
var $target = $(hash); // var $target = $(hash);
var offset = $target.offset(); // var offset = $target.offset();
if(!offset) { // if(!offset) {
$target = $('a[name='+hash.replace(/#/,'')+']'); // $target = $('a[name='+hash.replace(/#/,'')+']');
offset = $target.offset(); // offset = $target.offset();
} // }
if(offset) { // if(offset) {
e.preventDefault(); // e.preventDefault();
var newPos = offset.top - 10; // var newPos = offset.top - 10;
$('html, body').stop().animate( // $('html, body').stop().animate(
{'scrollTop': newPos}, 750, 'swing', function() { // {'scrollTop': newPos}, 750, 'swing', function() {
window.location.hash = hash; // window.location.hash = hash;
}); // });
} // }
}); // });
// champ de recherche dans le menu // champ de recherche dans le menu
$('.loupe > a').on('click', function(){ $('.loupe > a').on('click', function(){