Skip to content

Commit f6db501

Browse files
ArgoZhangrehee
andauthored
fix(Theme): update style to prevent flickering (#7505)
* fix(Theme): 修复抖动问题 * feat(Theme): 优化主题切换动画效果 Co-Authored-By: rehee <10417289+rehee@users.noreply.github.com>
1 parent e621359 commit f6db501

1 file changed

Lines changed: 17 additions & 7 deletions

File tree

src/BootstrapBlazor/wwwroot/scss/root.scss

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
@use "variables" as *;
1+
@use "variables" as *;
22

33
:root {
44
--bb-primary-color: #{$bb-primary-color};
@@ -82,35 +82,41 @@ a, a:hover, a:focus {
8282
display: none;
8383
}
8484

85-
::view-transition-old(*) {
85+
::view-transition-old(root) {
8686
mix-blend-mode: normal;
8787
animation: none;
8888
z-index: 1;
8989
}
9090

91-
::view-transition-new(*) {
91+
::view-transition-new(root) {
92+
will-change: clip-path, opacity;
9293
mix-blend-mode: normal;
93-
animation: clip .3s ease-in-out;
94+
animation: clip .3s ease-in-out both;
9495
z-index: 9999;
9596
}
9697

9798
@keyframes clip {
9899
from {
99100
clip-path: circle(0% at var(--bb-theme-x) var(--bb-theme-y));
101+
opacity: 0.99;
102+
transform: translateZ(0);
100103
}
101104

102105
to {
103106
clip-path: circle(100% at var(--bb-theme-x) var(--bb-theme-y));
107+
opacity: 1;
108+
transform: translateZ(0);
104109
}
105110
}
106111

107112
[data-bs-theme='dark'] {
108-
&::view-transition-old(*) {
109-
animation: clip2 .3s ease-in-out;
113+
&::view-transition-old(root) {
114+
will-change: clip-path, opacity;
115+
animation: clip2 .3s ease-in-out both;
110116
z-index: 9999;
111117
}
112118

113-
&::view-transition-new(*) {
119+
&::view-transition-new(root) {
114120
animation: none;
115121
z-index: 1;
116122
}
@@ -119,10 +125,14 @@ a, a:hover, a:focus {
119125
@keyframes clip2 {
120126
from {
121127
clip-path: circle(100% at var(--bb-theme-x) var(--bb-theme-y));
128+
opacity: 0.99;
129+
transform: translateZ(0);
122130
}
123131

124132
to {
125133
clip-path: circle(0% at var(--bb-theme-x) var(--bb-theme-y));
134+
opacity: 1;
135+
transform: translateZ(0);
126136
}
127137
}
128138

0 commit comments

Comments
 (0)