Skip to content

Commit 3704f75

Browse files
committed
Tween tab width
1 parent a019e38 commit 3704f75

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

packages/mini-editor/src/editor-frame.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ function TabsContainer({
161161

162162
type TabsSnapshot = Record<
163163
string,
164-
{ left: number; active: boolean }
164+
{ left: number; active: boolean; width: number }
165165
>
166166
type Snapshot = {
167167
titleBarHeight: number

packages/mini-editor/src/tabs.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,12 +110,16 @@ function getPanelTabs(
110110
const dx = prev
111111
? prev.left + (next.left - prev.left) * t
112112
: next.left
113+
const width = prev
114+
? prev.width + (next.width - prev.width) * t
115+
: next.width
113116
return {
114117
active: filename === active,
115118
title: filename,
116119
style: {
117120
position: "absolute" as const,
118121
transform: `translateX(${dx}px)`,
122+
width,
119123
},
120124
}
121125
})
@@ -139,6 +143,7 @@ function getPanelTabs(
139143
position: "absolute" as const,
140144
transform: `translateX(${next.left}px)`,
141145
opacity: t,
146+
width: next.width,
142147
},
143148
}
144149
})
@@ -179,6 +184,7 @@ function getPanelTabs(
179184
position: "absolute" as const,
180185
opacity: 1 - t,
181186
transform: `translateX(${prev.left}px)`,
187+
width: prev.width,
182188
},
183189
}
184190
})

packages/mini-editor/src/use-snapshots.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,10 @@ function getTabsDimensions(
131131
const dimensions = {} as TabsSnapshot
132132
tabElements.forEach(child => {
133133
const filename = child.getAttribute("title")!
134+
const rect = child.getBoundingClientRect()
134135
dimensions[filename] = {
135-
left: child.getBoundingClientRect().left - parentLeft,
136+
left: rect.left - parentLeft,
137+
width: rect.width,
136138
active: filename === active,
137139
}
138140
})

0 commit comments

Comments
 (0)