Skip to content

Commit b39f2b2

Browse files
authored
perf(anchor): reduce unnecessary calculations (#6516)
1 parent 019b539 commit b39f2b2

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

components/anchor/Anchor.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,6 @@ export default defineComponent({
131131
const { offsetTop, targetOffset } = props;
132132

133133
setCurrentActiveLink(link);
134-
const container = getContainer.value();
135-
const scrollTop = getScroll(container, true);
136134
const sharpLinkMatch = sharpMatcherRegx.exec(link);
137135
if (!sharpLinkMatch) {
138136
return;
@@ -142,6 +140,8 @@ export default defineComponent({
142140
return;
143141
}
144142

143+
const container = getContainer.value();
144+
const scrollTop = getScroll(container, true);
145145
const eleOffsetTop = getOffsetTop(targetElement, container);
146146
let y = scrollTop + eleOffsetTop;
147147
y -= targetOffset !== undefined ? targetOffset : offsetTop || 0;

0 commit comments

Comments
 (0)