Skip to content

Commit 9bfce7d

Browse files
committed
perf(core/anchor): use clip-path transition to avoid layout reflow on bar animation
1 parent e7d294c commit 9bfce7d

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

packages/core/src/anchor/_anchor-styles.scss

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,12 @@ $bar-width: 2px !default;
4141
content: '';
4242
position: absolute;
4343
left: 0;
44-
top: spacing.semantic-variable(gap, tight);
45-
bottom: spacing.semantic-variable(gap, tight);
44+
top: 0;
45+
bottom: 0;
4646
width: $bar-width;
47-
height: auto;
4847
background-color: palette.semantic-variable('border', neutral-faint);
49-
transition: transition.standard(background-color), transition.standard(top), transition.standard(bottom);
48+
clip-path: inset(spacing.semantic-variable(gap, tight) 0);
49+
transition: transition.standard(background-color), transition.standard(clip-path);
5050
}
5151

5252
&:hover {
@@ -58,8 +58,7 @@ $bar-width: 2px !default;
5858
position: relative;
5959

6060
&::before {
61-
top: 0;
62-
bottom: 0;
61+
clip-path: inset(0);
6362
background-color: palette.semantic-variable(text, brand);
6463
}
6564
}
@@ -75,8 +74,7 @@ $bar-width: 2px !default;
7574
box-shadow: effect.variable(focus, primary);
7675

7776
&::before {
78-
top: 0;
79-
bottom: 0;
77+
clip-path: inset(0);
8078
}
8179
}
8280
}

0 commit comments

Comments
 (0)