Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions layer/app/components/IconMenuToggle.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,16 @@ const props = defineProps<{

const { t } = useLocale()

const lineClass = 'outline-none origin-center [transform-box:fill-box] transition-[translate,rotate,opacity] duration-400 ease-[cubic-bezier(0.34,1.36,0.64,1)]'
// UHeader renders a second toggle in its menu overlay, mounted already open. Draw it closed for its
// first frame so the lines transition into the cross instead of appearing as one.
const ready = ref(false)
onMounted(() => requestAnimationFrame(() => requestAnimationFrame(() => {
ready.value = true
})))
const crossed = computed(() => props.open && ready.value)

// Each line turns around its own center; the overshoot approximates the spring the toggle used to have.
const lineClass = 'outline-none origin-center [transform-box:fill-box] transition-[translate,rotate,opacity] duration-300 ease-[cubic-bezier(0.34,1.56,0.64,1)] motion-reduce:transition-none'
</script>

<template>
Expand All @@ -34,21 +43,21 @@ const lineClass = 'outline-none origin-center [transform-box:fill-box] transitio
y1="6"
x2="20"
y2="6"
:class="[lineClass, props.open && 'translate-y-[6px] rotate-45']"
:class="[lineClass, crossed && 'translate-y-[6px] rotate-45']"
/>
<line
x1="4"
y1="12"
x2="20"
y2="12"
:class="[lineClass, props.open && 'opacity-0']"
:class="[lineClass, crossed && 'opacity-0']"
/>
<line
x1="4"
y1="18"
x2="20"
y2="18"
:class="[lineClass, props.open && '-translate-y-[6px] -rotate-45']"
:class="[lineClass, crossed && '-translate-y-[6px] -rotate-45']"
/>
</svg>
</UButton>
Expand Down
Loading