wix-storybook-utils
Version:
Utilities for automated component documentation within Storybook
24 lines (19 loc) • 431 B
text/typescript
const scrollToElement = element => {
element.scrollIntoView({
behavior: 'smooth',
inline: 'nearest',
});
};
export const scrollToElementByHash = () => {
const url = new URL(window.parent.location as any);
if (!url.hash) {
return;
}
setTimeout(() => {
const element = document.getElementById(url.hash.substring(1));
if (!element) {
return;
}
scrollToElement(element);
}, 600);
};