|
|
|
@ -32,7 +32,6 @@ export default memo(({ href, className, userId, children, type, addonId, ...othe
|
|
|
|
|
onClick={async evt => {
|
|
|
|
|
evt?.persist?.();
|
|
|
|
|
try {
|
|
|
|
|
console.log(href);
|
|
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
@ -44,20 +43,23 @@ export default memo(({ href, className, userId, children, type, addonId, ...othe
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
if (href?.startsWith('#')) {
|
|
|
|
|
evt.preventDefault();
|
|
|
|
|
const topOfElement = document.querySelector(`#${href.substring(1)}`)?.offsetTop;
|
|
|
|
|
const scroller = document.querySelector('.vz-dashboard-scroller');
|
|
|
|
|
/**
|
|
|
|
|
* If the elements don't exist at the check, just load the page normally as if
|
|
|
|
|
* there was no hash.
|
|
|
|
|
*/
|
|
|
|
|
if (!topOfElement || !scroller) {
|
|
|
|
|
return;
|
|
|
|
|
evt?.preventDefault?.();
|
|
|
|
|
const selector = document.querySelector(`#${href.substring(1)}`);
|
|
|
|
|
if (selector) {
|
|
|
|
|
const topOfElement = selector.offsetTop;
|
|
|
|
|
const scroller = document.querySelector('.vz-dashboard-scroller');
|
|
|
|
|
/**
|
|
|
|
|
* If the elements don't exist at the check, just load the page normally as if
|
|
|
|
|
* there was no hash.
|
|
|
|
|
*/
|
|
|
|
|
if (!topOfElement || !scroller) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* Try to set the scroller position to the hash element.
|
|
|
|
|
*/
|
|
|
|
|
return scroller.scroll({ top: topOfElement - 80, behavior: 'smooth' });
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* Try to set the scroller position to the hash element.
|
|
|
|
|
*/
|
|
|
|
|
return scroller.scroll({ top: topOfElement - 30, behavior: 'smooth' });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|