Skip to content

Commit 2a39a07

Browse files
Don't animate on scaling + add more keyframes
1 parent 8959d57 commit 2a39a07

File tree

1 file changed

+54
-17
lines changed

1 file changed

+54
-17
lines changed

assets/theme-css/sphinx-design/_dropdown.scss

Lines changed: 54 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -108,44 +108,53 @@ details.sd-dropdown {
108108
.sd-summary-chevron-down i {
109109
display: inline-block;
110110
transform-origin: center;
111-
transition:
112-
transform 0.25s ease-in-out,
113-
opacity 0.25s ease-in-out;
114111
opacity: 0.6;
115112
}
116113

117114
// The chevron rotation animations are applied to
118115
// the icon inside the dropdown title div
119116
&[open] > .sd-summary-title .sd-summary-chevron-right i {
120117
transform: rotate(90deg);
118+
animation: rotate-to-90 0.25s ease-in-out;
121119
}
122120

123121
&[open] > .sd-summary-title .sd-summary-chevron-down i {
124122
transform: rotate(180deg);
123+
animation: rotate-to-180 0.25s ease-in-out;
125124
}
126125

127-
&:hover .sd-summary-chevron-right i,
128-
&:hover .sd-summary-chevron-down i {
126+
&:not([open]) > .sd-summary-title .sd-summary-chevron-right i {
127+
transform: rotate(0deg);
128+
animation: rotate-to-0-from-90 0.25s ease-in-out;
129+
}
130+
131+
&:not([open]) > .sd-summary-title .sd-summary-chevron-down i {
132+
transform: rotate(0deg);
133+
animation: rotate-to-0-from-180 0.25s ease-in-out;
134+
}
135+
136+
> .sd-summary-title:hover .sd-summary-chevron-right i,
137+
> .sd-summary-title:hover .sd-summary-chevron-down i {
129138
opacity: 1;
130139
}
131140

132141
// Combined transforms for each state with hover. These cover
133142
// the cases where the chevron is rotated, say, when the dropdown
134143
// is open or if the chevron starts rotated (e.g. in the down-up
135144
// state).
136-
&:not([open]):hover .sd-summary-chevron-right i {
145+
&:not([open]) > .sd-summary-title:hover .sd-summary-chevron-right i {
137146
transform: scale(1.1);
138147
}
139148

140-
&:not([open]):hover .sd-summary-chevron-down i {
149+
&:not([open]) > .sd-summary-title:hover .sd-summary-chevron-down i {
141150
transform: scale(1.1);
142151
}
143152

144-
&[open]:hover > .sd-summary-title .sd-summary-chevron-right i {
153+
&[open] > .sd-summary-title:hover .sd-summary-chevron-right i {
145154
transform: rotate(90deg) scale(1.1);
146155
}
147156

148-
&[open]:hover > .sd-summary-title .sd-summary-chevron-down i {
157+
&[open] > .sd-summary-title:hover .sd-summary-chevron-down i {
149158
transform: rotate(180deg) scale(1.1);
150159
}
151160

@@ -160,18 +169,10 @@ details.sd-dropdown {
160169

161170
// Transition animation
162171
&.sd-fade-in[open] summary ~ * {
163-
-moz-animation: sd-fade-in 0.5s ease-in-out;
164-
-webkit-animation: sd-fade-in 0.5s ease-in-out;
165172
animation: sd-fade-in 0.5s ease-in-out;
166173
}
167174

168175
&.sd-fade-in-slide-down[open] summary ~ * {
169-
-moz-animation:
170-
sd-fade-in 0.5s ease-in-out,
171-
sd-slide-down 0.5s ease-in-out;
172-
-webkit-animation:
173-
sd-fade-in 0.5s ease-in-out,
174-
sd-slide-down 0.5s ease-in-out;
175176
animation:
176177
sd-fade-in 0.5s ease-in-out,
177178
sd-slide-down 0.5s ease-in-out;
@@ -205,3 +206,39 @@ details.sd-dropdown {
205206
transform: translate(0, 0);
206207
}
207208
}
209+
210+
@keyframes rotate-to-90 {
211+
from {
212+
transform: rotate(0deg) scale(1.1);
213+
}
214+
to {
215+
transform: rotate(90deg) scale(1.1);
216+
}
217+
}
218+
219+
@keyframes rotate-to-180 {
220+
from {
221+
transform: rotate(0deg) scale(1.1);
222+
}
223+
to {
224+
transform: rotate(180deg) scale(1.1);
225+
}
226+
}
227+
228+
@keyframes rotate-to-0-from-90 {
229+
from {
230+
transform: rotate(90deg) scale(1.1);
231+
}
232+
to {
233+
transform: rotate(0deg) scale(1.1);
234+
}
235+
}
236+
237+
@keyframes rotate-to-0-from-180 {
238+
from {
239+
transform: rotate(180deg) scale(1.1);
240+
}
241+
to {
242+
transform: rotate(0deg) scale(1.1);
243+
}
244+
}

0 commit comments

Comments
 (0)