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