@mapbox/batfish
Version:
The React-powered static-site generator you didn't know you wanted
12 lines (10 loc) • 319 B
JavaScript
//
// Check the current location for a hash, and if there is one try to scroll to it.
export function scrollToFragment() {
const fragment = window.location.hash;
if (!fragment) return;
const element = document.getElementById(fragment.replace('#', ''));
if (element) {
element.scrollIntoView();
}
}