improve popout animations (#7040)

This commit is contained in:
Prospector
2026-08-07 13:19:56 -07:00
committed by GitHub
parent 75335647ee
commit bca5303ae3
7 changed files with 230 additions and 230 deletions
+1 -7
View File
@@ -97,12 +97,7 @@
</ButtonFrame> </ButtonFrame>
<Teleport to="#teleports"> <Teleport to="#teleports">
<Transition <Transition name="floating-expand">
enter-active-class="transition-opacity duration-150"
leave-active-class="transition-opacity duration-150"
enter-from-class="opacity-0"
leave-to-class="opacity-0"
>
<div <div
v-if="shouldRenderDropdown" v-if="shouldRenderDropdown"
ref="dropdownRef" ref="dropdownRef"
@@ -110,7 +105,6 @@
:class="[ :class="[
props.dropdownClass, props.dropdownClass,
openDirection === 'up' ? 'shadow-[0_-25px_50px_-12px_rgb(0,0,0,0.25)]' : 'shadow-2xl', openDirection === 'up' ? 'shadow-[0_-25px_50px_-12px_rgb(0,0,0,0.25)]' : 'shadow-2xl',
props.dropdownClass,
]" ]"
:style="dropdownStyle" :style="dropdownStyle"
:role="listbox ? 'listbox' : 'menu'" :role="listbox ? 'listbox' : 'menu'"
@@ -128,12 +128,7 @@
</div> </div>
<Teleport to="#teleports"> <Teleport to="#teleports">
<Transition <Transition name="floating-expand" :css="!isMobileAddMenuLayout">
:enter-active-class="addMenuTransitionEnterActiveClass"
leave-active-class="transition-none duration-0"
:enter-from-class="addMenuTransitionEnterFromClass"
leave-to-class="opacity-0"
>
<div <div
v-if="isAddMenuOpen && !isMobileActiveSubmenu" v-if="isAddMenuOpen && !isMobileActiveSubmenu"
ref="menuContainer" ref="menuContainer"
@@ -166,6 +161,7 @@
</Teleport> </Teleport>
<Teleport to="#teleports"> <Teleport to="#teleports">
<Transition name="floating-expand" :css="!isMobileAddMenuLayout">
<div <div
v-if="isAddMenuOpen && activeCategory && (isMobileAddMenuLayout || hasSubmenuPosition)" v-if="isAddMenuOpen && activeCategory && (isMobileAddMenuLayout || hasSubmenuPosition)"
ref="submenu" ref="submenu"
@@ -211,7 +207,10 @@
></slot> ></slot>
</div> </div>
<div v-if="$slots['category-top']" class="border-0 border-b border-solid border-b-surface-5"> <div
v-if="$slots['category-top']"
class="border-0 border-b border-solid border-b-surface-5"
>
<slot <slot
name="category-top" name="category-top"
:category="activeCategory" :category="activeCategory"
@@ -266,7 +265,9 @@
<div <div
v-for="{ item, index } in renderedVisibleActiveCategoryOptions" v-for="{ item, index } in renderedVisibleActiveCategoryOptions"
:key="getActiveCategoryItemKey(item, index)" :key="getActiveCategoryItemKey(item, index)"
:class="shouldVirtualizeActiveCategoryOptions ? 'absolute left-0 right-0' : undefined" :class="
shouldVirtualizeActiveCategoryOptions ? 'absolute left-0 right-0' : undefined
"
:style="getActiveCategoryOptionWrapperStyle(index)" :style="getActiveCategoryOptionWrapperStyle(index)"
> >
<div <div
@@ -367,6 +368,7 @@
:close-menu="closeAddMenu" :close-menu="closeAddMenu"
></slot> ></slot>
</div> </div>
</Transition>
</Teleport> </Teleport>
</template> </template>
@@ -726,12 +728,6 @@ const isMobileActiveSubmenu = computed(
() => () =>
isMobileAddMenuLayout.value && activeCategory.value !== undefined && hasSubmenuPosition.value, isMobileAddMenuLayout.value && activeCategory.value !== undefined && hasSubmenuPosition.value,
) )
const addMenuTransitionEnterActiveClass = computed(() =>
isMobileAddMenuLayout.value ? 'transition-none duration-0' : 'transition-opacity duration-150',
)
const addMenuTransitionEnterFromClass = computed(() =>
isMobileAddMenuLayout.value ? 'opacity-100' : 'opacity-0',
)
const addMenuTriggerElement = computed(() => addMenuTrigger.value?.element ?? null) const addMenuTriggerElement = computed(() => addMenuTrigger.value?.element ?? null)
const addMenuOutsideClickTarget = computed(() => menuContainer.value ?? submenu.value) const addMenuOutsideClickTarget = computed(() => menuContainer.value ?? submenu.value)
const addMenuOutsideClickIgnore = computed(() => [addMenuTriggerElement, menuContainer, submenu]) const addMenuOutsideClickIgnore = computed(() => [addMenuTriggerElement, menuContainer, submenu])
@@ -108,12 +108,7 @@
</component> </component>
<Teleport to="#teleports"> <Teleport to="#teleports">
<Transition <Transition name="floating-expand">
enter-active-class="transition-opacity duration-150"
leave-active-class="transition-opacity duration-150"
enter-from-class="opacity-0"
leave-to-class="opacity-0"
>
<div <div
v-if="isOpen" v-if="isOpen"
ref="dropdownRef" ref="dropdownRef"
@@ -80,6 +80,19 @@ const { isOpen, panelStyle, anchorStyle, resolvedSide, open, close } = useAnchor
resolvedDistance, resolvedDistance,
) )
const menuTransformOrigin = computed(() => {
switch (resolvedSide.value) {
case 'top':
return 'bottom center'
case 'left':
return 'right center'
case 'right':
return 'left center'
default:
return 'top center'
}
})
const menuItemClasses = const menuItemClasses =
'overflow-menu-item flex min-h-10 w-full items-center gap-2 rounded-[10px] border-0 bg-transparent px-3 py-2 text-left text-base font-semibold leading-5 text-contrast no-underline ' + 'overflow-menu-item flex min-h-10 w-full items-center gap-2 rounded-[10px] border-0 bg-transparent px-3 py-2 text-left text-base font-semibold leading-5 text-contrast no-underline ' +
'cursor-pointer whitespace-nowrap hover:bg-surface-4 focus-visible:bg-surface-4 focus-visible:outline-none ' + 'cursor-pointer whitespace-nowrap hover:bg-surface-4 focus-visible:bg-surface-4 focus-visible:outline-none ' +
@@ -294,20 +307,13 @@ defineExpose({ open: openMenu, close: closeMenu })
</component> </component>
<Teleport to="body"> <Teleport to="body">
<Transition <Transition name="floating-expand">
enter-active-class="transition duration-125 ease-out"
enter-from-class="scale-95 opacity-0"
enter-to-class="scale-100 opacity-100"
leave-active-class="transition duration-100 ease-in"
leave-from-class="scale-100 opacity-100"
leave-to-class="scale-95 opacity-0"
>
<div <div
v-if="isOpen" v-if="isOpen"
:id="menuId" :id="menuId"
ref="panelElement" ref="panelElement"
class="fixed isolate z-[9999] flex min-w-48 flex-col gap-1 rounded-[14px] bg-surface-3 p-2 shadow-lg ring-1 ring-surface-5" class="fixed isolate z-[9999] flex min-w-48 flex-col gap-1 rounded-[14px] bg-surface-3 p-2 shadow-lg ring-1 ring-surface-5"
:style="panelStyle" :style="[panelStyle, { transformOrigin: menuTransformOrigin }]"
role="menu" role="menu"
:aria-label="props.label" :aria-label="props.label"
@keydown="handleMenuKeydown" @keydown="handleMenuKeydown"
@@ -123,14 +123,7 @@ defineExpose({ open: openMenu, close: closeMenu })
</component> </component>
<Teleport to="body"> <Teleport to="body">
<Transition <Transition name="floating-expand">
enter-active-class="transition duration-125 ease-out"
enter-from-class="scale-95 opacity-0"
enter-to-class="scale-100 opacity-100"
leave-active-class="transition duration-100 ease-in"
leave-from-class="scale-100 opacity-100"
leave-to-class="scale-95 opacity-0"
>
<div <div
v-if="isOpen" v-if="isOpen"
:id="panelId" :id="panelId"
@@ -1,18 +1,11 @@
<template> <template>
<Teleport to="#teleports"> <Teleport to="#teleports">
<Transition <Transition name="floating-expand">
enter-active-class="transition duration-125 ease-out"
enter-from-class="transform scale-75 opacity-0"
enter-to-class="transform scale-100 opacity-100"
leave-active-class="transition duration-125 ease-in"
leave-from-class="transform scale-100 opacity-100"
leave-to-class="transform scale-75 opacity-0"
>
<div <div
v-if="visible" v-if="visible"
ref="menuRef" ref="menuRef"
class="fixed isolate z-[9999] flex w-fit min-w-[180px] flex-col gap-2 overflow-hidden rounded-2xl border border-solid border-surface-5 bg-bg-raised p-2 shadow-lg" class="fixed isolate z-[9999] flex w-fit min-w-[180px] flex-col gap-2 overflow-hidden rounded-2xl border border-solid border-surface-5 bg-bg-raised p-2 shadow-lg"
:style="{ left: `${position.x}px`, top: `${position.y}px` }" :style="{ left: `${position.x}px`, top: `${position.y}px`, transformOrigin: 'top left' }"
role="menu" role="menu"
tabindex="-1" tabindex="-1"
@mousedown.stop @mousedown.stop
@@ -1,3 +1,26 @@
:root {
--ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
}
.floating-expand-enter-from,
.floating-expand-leave-to {
opacity: 0;
scale: 0.9 0.3;
}
.floating-expand-enter-to,
.floating-expand-leave-from {
opacity: 1;
}
.floating-expand-enter-active,
.floating-expand-leave-active {
transition:
opacity 0.125s var(--ease-out-expo),
scale 0.125s var(--ease-out-expo);
transform-origin: top;
}
@layer utilities { @layer utilities {
.heading-xl { .heading-xl {
@apply m-0 text-xl font-semibold leading-none text-contrast; @apply m-0 text-xl font-semibold leading-none text-contrast;