Sure @Marcel, this should work (not tested though):
<script>
function smoothScrollTo(element, duration = 1200, offset = 100) {
const targetPosition = element.getBoundingClientRect().top - offset;
const startPosition = window.pageYOffset;
const distance = targetPosition - startPosition;
let startTime = null;
function animation(currentTime) {
if (startTime === null) startTime = currentTime;
const timeElapsed = currentTime - startTime;
const ease = easeInOutCubic(timeElapsed, startPosition, distance, duration);
window.scrollTo(0, ease);
if (timeElapsed < duration) requestAnimationFrame(animation);
}
function easeInOutCubic(t, b, c, d) {
t /= d / 2;
if (t < 1) return c / 2 * t * t * t + b;
t -= 2;
return c / 2 * (t * t * t + 2) + b;
}
requestAnimationFrame(animation);
}
window.addEventListener('load', function() {
var hash = window.location.hash;
if (hash) {
var element = document.querySelector(hash);
if (element) {
smoothScrollTo(element);
}
}
});
</script>