Skip to content

Commit f88e7a3

Browse files
yel-haddclaude
andcommitted
Fix search drawer close-animation flashing on initial page load
The .drawer element starts hidden (translateY(-100%)) and carried an unconditional `transition: 0.4s ease`. On first load the transition could run as the hidden state was applied, briefly flashing the close animation. The transition is now applied via a `.drawer--animated` class that is only added after the component mounts (double rAF), so the initial hidden state is applied instantly with no animation. Genuine open/close toggles still animate as before. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 85bcdfb commit f88e7a3

1 file changed

Lines changed: 18 additions & 3 deletions

File tree

docs/.vuepress/theme/drawer/Drawer.vue

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<template>
22
<div>
3-
<div class="drawer" :class="{'is-open': isOpenDrawer}">
3+
<div class="drawer" :class="{'is-open': isOpenDrawer, 'drawer--animated': animationsReady}">
44
<div class="drawer-header">
55
<div class="drawer-header__wrapper">
66
<h2 class="drawer-header__paragraph">How can we help you?</h2>
@@ -30,7 +30,7 @@
3030
<script setup>
3131
import { withBase } from "@vuepress/client";
3232
import Footer from "../footer/Footer.vue";
33-
import { computed, ref, watch } from "vue";
33+
import { computed, onMounted, ref, watch } from "vue";
3434
import DrawerSearchResult from "./DrawerSearchResult.vue";
3535
3636
const props = defineProps({
@@ -66,6 +66,16 @@ const onCloseDrawer = () => {
6666
emit('closeDrawer');
6767
}
6868
69+
// The drawer starts hidden (translateY(-100%)). Enabling the slide transition
70+
// only after the first paint prevents the close animation from flashing on
71+
// initial page load — it then fires only on genuine open/close toggles.
72+
const animationsReady = ref(false);
73+
onMounted(() => {
74+
requestAnimationFrame(() => requestAnimationFrame(() => {
75+
animationsReady.value = true;
76+
}));
77+
});
78+
6979
watch(() => props.isOpenDrawer, () => {
7080
document.body.classList.toggle('disable-scroll', props.isOpenDrawer);
7181
});
@@ -89,7 +99,12 @@ watch(() => props.isOpenDrawer, () => {
8999
background: $drawerHeaderBgColor
90100
opacity: 0;
91101
transform: translateY(-100%);
92-
transition: 0.4s ease;
102+
103+
// Transition is intentionally NOT set here so the initial hidden state is
104+
// applied instantly (no flash on first load). It is enabled via
105+
// .drawer--animated once the component has mounted.
106+
&.drawer--animated
107+
transition: 0.4s ease
93108
94109
&-header
95110
padding 1.25rem $layout-horizontal-padding

0 commit comments

Comments
 (0)