@@ -69,10 +69,14 @@ const parent = computed(() => props.teleportTo ?? toValue(injectedParent));
6969
7070const internalHidden = ref (props .hidden );
7171const opacity = ref (props .hidden ? 0 : 1 );
72+ const isVisible = ref (false );
7273
7374watch (() => props .hidden , (hidden ) => {
7475 if (hidden ) {
7576 opacity .value = 0 ;
77+ if (! isVisible .value ) {
78+ internalHidden .value = true ;
79+ }
7680 } else if (internalHidden .value ) {
7781 internalHidden .value = false ;
7882 } else {
@@ -152,7 +156,7 @@ function floatingElement() {
152156
153157 const onElementMounted = (el : unknown ) => {
154158 htmlElement .value = el instanceof HTMLElement ? el : null ;
155- opacity .value = props . hidden ? 0 : 1 ;
159+ opacity .value = 1 ;
156160 };
157161
158162 return withDirectives (cloneVNode (children [0 ], {
@@ -165,10 +169,16 @@ function floatingElement() {
165169 transition: ` opacity ${props .animationDuration }ms cubic-bezier(.54, 1.5, .38, 1.11) ` ,
166170 zIndex: props .zIndex ,
167171 },
172+ onTransitionstart : (e : TransitionEvent ) => {
173+ if (e .propertyName === ' opacity' && opacity .value > 0 ) {
174+ isVisible .value = true ;
175+ }
176+ },
168177 onTransitionend : (e : TransitionEvent ) => {
169178 if (e .propertyName === ' opacity' ) {
170179 if (! opacity .value ) {
171180 internalHidden .value = true ;
181+ isVisible .value = false ;
172182 emit (' hidden' );
173183 } else {
174184 emit (' shown' );
0 commit comments