in src/utils/router-utils.js [40:68]
export async function scrollBehavior(to, from, savedPosition) {
if (savedPosition) {
// Wait until the page has been rendered, then scroll to the saved
// position. If we resolve too early, `savedPosition.y` could be
// outside the bounds of the app's non-rendered page, which is
// header + loading-placeholder + footer. This would result in the
// browser displaying the top of the page and no scrolling to occur.
await this.app.$nextTick();
return savedPosition;
}
if (to.hash) {
const { name, query, hash } = to;
const isDocumentation = name.includes(documentationTopicName);
const hasNavBarOpen = !!query.changes;
const baseNavOffset = getBaseNavOffset();
// if on docs and have API changes enabled
const apiChangesNavHeight = (isDocumentation && hasNavBarOpen) ? baseNavOffset : 0;
// compensate for the nav sticky height.
const offset = baseNavOffset + apiChangesNavHeight;
const y = process.env.VUE_APP_TARGET === 'ide' ? 0 : offset;
return { selector: cssEscapeTopicIdHash(hash), offset: { x: 0, y } };
}
if (areEquivalentLocations(to, from)) {
// Do not change the scroll position if the location hasn't changed.
return false;
}
return { x: 0, y: 0 };
}