Skip to content

Commit 848a8e2

Browse files
committed
fix(web): header animation glitches fixed
1 parent 52447fc commit 848a8e2

2 files changed

Lines changed: 16 additions & 12 deletions

File tree

apps/web/src/components/ui/header/index.tsx

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ const Header = () => {
123123
<div className="w-full fixed top-0 left-0 right-0 z-50">
124124
<nav className="w-fit mx-auto space-y-4 p-4">
125125
<motion.div
126-
layout="preserve-aspect"
126+
layout="position"
127127
initial={{ opacity: 0, scale: 0.95 }}
128128
animate={{ opacity: 1, scale: 1 }}
129129
exit={{ opacity: 0, scale: 0.95 }}
@@ -150,15 +150,17 @@ const Header = () => {
150150
<Logo className="w-8 h-8" />
151151
</motion.button>
152152
</motion.div>
153-
<AnimatePresence mode="popLayout">
153+
<AnimatePresence>
154154
{!isSearchOpen && (
155155
<motion.div
156-
layout="position"
156+
key="tabs"
157+
layout
157158
initial={hasMounted ? "initial" : false}
158159
animate="animate"
159160
exit="exit"
160161
variants={tabsContainerVariants}
161162
transition={tabsContainerTransition}
163+
style={{ overflow: "hidden" }}
162164
>
163165
<motion.div
164166
initial={{ backdropFilter: "blur(0px)" }}
@@ -180,15 +182,17 @@ const Header = () => {
180182
</motion.div>
181183
)}
182184
</AnimatePresence>
183-
<AnimatePresence mode="popLayout">
185+
<AnimatePresence>
184186
{!isOnSettingsPage && (
185187
<motion.div
186-
layout="position"
188+
key="search"
189+
layout
187190
initial={hasMounted ? "initial" : false}
188191
animate="animate"
189192
exit="exit"
190193
variants={searchContainerVariants}
191194
transition={searchContainerTransition}
195+
style={{ transformOrigin: "left center" }}
192196
className="border bg-neutral-900/60 !backdrop-blur-lg border-white/10 rounded-[50px] flex items-center ml-2"
193197
>
194198
<div className="p-1">
@@ -237,7 +241,7 @@ const Header = () => {
237241
)}
238242
</AnimatePresence>
239243
<motion.div
240-
layout="position"
244+
layout
241245
transition={{ layout: { duration: 0.3, ease: [0.4, 0, 0.2, 1] } }}
242246
>
243247
<UserMenu />

apps/web/src/components/ui/header/variants.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
export const tabsContainerVariants = {
2-
initial: { width: 0, opacity: 0 },
3-
animate: { width: "auto", opacity: 1 },
4-
exit: { width: 0, opacity: 0 },
2+
initial: { width: 0, opacity: 0, x: 0 },
3+
animate: { width: "auto", opacity: 1, x: 0 },
4+
exit: { width: 0, opacity: 0, x: 0 },
55
};
66

77
export const tabsContainerTransition = {
@@ -14,9 +14,9 @@ export const tabsContainerTransition = {
1414
};
1515

1616
export const searchContainerVariants = {
17-
initial: { scale: 0, opacity: 0, originX: 0 },
18-
animate: { scale: 1, opacity: 1 },
19-
exit: { scale: 0, opacity: 0, originX: 0 },
17+
initial: { width: 0, opacity: 0 },
18+
animate: { width: "auto", opacity: 1 },
19+
exit: { width: 0, opacity: 0 },
2020
};
2121

2222
export const searchContainerTransition = {

0 commit comments

Comments
 (0)