Docuthèque

{source}<script>
$(document).ready(function () {
const anchors = [
"babyhand",
"u18m", "u18f",
"u15m", "u15f",
"u13m", "u13f",
"u11m", "u11f",
"u9m", "loisir",
"he", "hf"
];

const hash = window.location.hash.replace("#", "");
if (anchors.includes(hash)) {
const target = $("#" + hash);
if (target.length) {
setTimeout(() => {
// Offset responsive
let offset = 170;
if (window.innerWidth > 992) {
offset = 180;
} else if (window.innerWidth > 768) {
offset = 170;
} else {
offset = 160;
}

// Calcul distance
const scrollTop = $(window).scrollTop();
const targetTop = target.offset().top - offset;
const distance = Math.abs(targetTop - scrollTop);

// Durée dynamique
const duration = distance / 1.53;

// Défilement doux avec effet swing
$("html, body").animate({
scrollTop: targetTop
}, duration, "swing");
}, 100);
}
}
});
</script>
{/source}