@@ -45,6 +45,7 @@ const stack = ref(null);
4545const mounted = ref (false );
4646const visible = ref (false );
4747const isHovering = ref (false );
48+ const isStackEntering = ref (false );
4849const escBinding = ref (null );
4950const windowInnerWidth = ref (window .innerWidth );
5051
@@ -91,6 +92,18 @@ const leftOffset = computed(() => {
9192const hasChild = computed (() => stacks .count () > depth .value );
9293const direction = computed (() => config .get (' direction' , ' ltr' ));
9394
95+ const containerStyle = computed (() => {
96+ if (props .size === ' full' ) {
97+ return direction .value === ' ltr' ? { left: 0 , transform: ' translateZ(0)' } : { right: 0 , transform: ' translateZ(0)' };
98+ }
99+ const x = leftOffset .value ;
100+ const width = ` calc(100% - ${ x} px)` ;
101+ if (direction .value === ' ltr' ) {
102+ return { left: 0 , width, transform: ` translateX(${ x} px) translateZ(0)` };
103+ }
104+ return { right: 0 , width, transform: ` translateX(-${ x} px) translateZ(0)` };
105+ });
106+
94107const clickedHitArea = () => {
95108 if (! visible .value ) return ;
96109 if (! runCloseCallback ()) return ;
@@ -111,14 +124,21 @@ const mouseOutHitArea = () => {
111124};
112125
113126const windowResized = () => windowInnerWidth .value = window .innerWidth ;
127+ const stackEnteringChanged = (entering ) => {
128+ isStackEntering .value = entering;
129+
130+ if (entering) {
131+ isHovering .value = false ;
132+ }
133+ };
114134
115135function open () {
116136 if (! stack .value ) stack .value = stacks .add (instance .proxy );
117137
118138 events .$on (` stacks.${ depth .value } .hit-area-mouseenter` , () => (isHovering .value = true ));
119139 events .$on (` stacks.${ depth .value } .hit-area-mouseout` , () => (isHovering .value = false ));
120140
121- escBinding .value = keys .bindGlobal (' esc' , close );
141+ escBinding .value = keys .bindGlobal (' esc' , runCloseCallback );
122142
123143 window .addEventListener (' resize' , windowResized);
124144
@@ -180,10 +200,13 @@ watch(
180200);
181201
182202onMounted (() => {
203+ events .$on (' stacks.entering' , stackEnteringChanged);
204+
183205 if (props .open ) open ();
184206});
185207
186208onBeforeUnmount (() => {
209+ events .$off (' stacks.entering' , stackEnteringChanged);
187210 cleanup ();
188211});
189212
@@ -202,21 +225,18 @@ provide('closeStack', close);
202225 < / Primitive>
203226 < teleport : to= " portal" : order= " depth" v- if = " mounted" >
204227 < div class = " vue-portal-target stack" >
228+ < div
229+ class = " stack-overlay fixed inset-0 bg-gray-800/20 dark:bg-gray-800/50 transition-opacity duration-200 ease-out"
230+ : class = " visible ? 'opacity-100' : 'opacity-0'"
231+ / >
232+
205233 < FocusScope
206234 : trapped= " isTopPortal"
207235 loop
208236 class = " stack-container outline-none"
209237 : class = " { 'stack-is-current': isTopStack }"
210- : style= " direction === 'ltr' ? { left: `${leftOffset}px` } : { right: `${leftOffset}px` } "
238+ : style= " containerStyle "
211239 >
212- < transition name= " stack-overlay-fade" >
213- < div
214- v- if = " visible"
215- class = " stack-overlay fixed inset-0 bg-gray-800/20 dark:bg-gray-800/50"
216- : style= " direction === 'ltr' ? { left: `-${leftOffset}px` } : { right: `-${leftOffset}px` }"
217- / >
218- < / transition>
219-
220240 < div
221241 class = " stack-hit-area"
222242 : style= " direction === 'ltr' ? { left: `-${offset}px` } : { right: `-${offset}px` }"
@@ -231,7 +251,7 @@ provide('closeStack', close);
231251 class = " stack-content fixed flex flex-col sm:end-1.5 bg-content-bg dark:bg-dark-content-bg overflow-hidden rounded-xl shadow-[0_8px_5px_-6px_rgba(0,0,0,0.1),_0_3px_8px_0_rgba(0,0,0,0.02),_0_30px_22px_-22px_rgba(39,39,42,0.15)] dark:shadow-[0_5px_20px_rgba(0,0,0,.5)] transition-transform duration-200 ease-out will-change-transform"
232252 : class = " [
233253 size === 'full' ? 'inset-2 w-[calc(100svw-1rem)]' : 'inset-y-2',
234- { '-translate-x-4 rtl:translate-x-4': isHovering }
254+ { '-translate-x-4 rtl:translate-x-4': isHovering && !isStackEntering }
235255 ]"
236256 >
237257 < template v- if = " shouldAddHeader" >
0 commit comments