perf(anchor): reduce unnecessary calculations (#6516)
parent
019b539f16
commit
b39f2b2d03
|
@ -131,8 +131,6 @@ export default defineComponent({
|
|||
const { offsetTop, targetOffset } = props;
|
||||
|
||||
setCurrentActiveLink(link);
|
||||
const container = getContainer.value();
|
||||
const scrollTop = getScroll(container, true);
|
||||
const sharpLinkMatch = sharpMatcherRegx.exec(link);
|
||||
if (!sharpLinkMatch) {
|
||||
return;
|
||||
|
@ -142,6 +140,8 @@ export default defineComponent({
|
|||
return;
|
||||
}
|
||||
|
||||
const container = getContainer.value();
|
||||
const scrollTop = getScroll(container, true);
|
||||
const eleOffsetTop = getOffsetTop(targetElement, container);
|
||||
let y = scrollTop + eleOffsetTop;
|
||||
y -= targetOffset !== undefined ? targetOffset : offsetTop || 0;
|
||||
|
|
Loading…
Reference in New Issue