Skip to content

Commit bd6b5dd

Browse files
committed
[fix] don't run animation during opening the menu
Fixes sveltejs#123
1 parent 7c23e62 commit bd6b5dd

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/routes/tutorial/[slug]/Menu.svelte

+9-3
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,19 @@
1818
1919
let expanded_part = '';
2020
let expanded_chapter = '';
21+
let duration = 0;
2122
22-
$: if (is_open) {
23+
// The following statements ensure that the select animation is not run during opening the menu
24+
$: if (is_open || !is_open) {
2325
expanded_part = current.part.slug;
2426
expanded_chapter = current.chapter.slug;
2527
}
26-
27-
const duration = browser && matchMedia('(prefers-reduced-motion: reduce)').matches ? 0 : 200;
28+
$: if (is_open) {
29+
duration = 0;
30+
setTimeout(() => {
31+
duration = browser && matchMedia('(prefers-reduced-motion: reduce)').matches ? 0 : 200;
32+
}, 210);
33+
}
2834
2935
$: regex = new RegExp(`\\b${search.length >= 2 ? search : ''}`, 'i');
3036

0 commit comments

Comments
 (0)