Skip to content

Commit 98b3654

Browse files
perf: buttery smooth pane resize using CSS custom properties, bypass reactivity during drag
1 parent 49275d8 commit 98b3654

1 file changed

Lines changed: 23 additions & 5 deletions

File tree

  • crates/tauri-app/frontend/src

crates/tauri-app/frontend/src/App.tsx

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ export function App() {
4040
const [draggingDivider, setDraggingDivider] = createSignal(false);
4141
const [isVertical, setIsVertical] = createSignal(false);
4242
let bodyRef: HTMLDivElement | undefined;
43+
let chatPercentRef = 60;
4344

4445
// Whether active thread is in a git-activated project
4546
const isGitProject = () => {
@@ -102,10 +103,16 @@ export function App() {
102103
} else {
103104
pct = ((ev.clientX - rect.left) / rect.width) * 100;
104105
}
105-
setChatPercent(Math.min(Math.max(pct, 25), 80));
106+
pct = Math.min(Math.max(pct, 25), 80);
107+
// Set CSS custom property directly — bypasses SolidJS reactivity for smooth drag
108+
bodyRef.style.setProperty("--chat-pct", `${pct}%`);
109+
bodyRef.style.setProperty("--side-pct", `${100 - pct}%`);
110+
chatPercentRef = pct;
106111
};
107112
const onUp = () => {
108113
setDraggingDivider(false);
114+
// Sync back to signal for persistence
115+
setChatPercent(chatPercentRef);
109116
window.removeEventListener("mousemove", onMove);
110117
window.removeEventListener("mouseup", onUp);
111118
document.body.style.cursor = "";
@@ -156,16 +163,18 @@ export function App() {
156163

157164
const chatStyle = () => {
158165
if (!hasSidePane()) return {};
166+
const pct = `var(--chat-pct, ${chatPercent()}%)`;
159167
return isVertical()
160-
? { height: `${chatPercent()}%`, "min-height": "120px" }
161-
: { width: `${chatPercent()}%`, "min-width": "200px" };
168+
? { height: pct, "min-height": "120px" }
169+
: { width: pct, "min-width": "200px" };
162170
};
163171

164172
const sideStyle = () => {
165173
if (!hasSidePane()) return {};
174+
const pct = `var(--side-pct, ${100 - chatPercent()}%)`;
166175
return isVertical()
167-
? { height: `${100 - chatPercent()}%`, "min-height": "120px" }
168-
: { width: `${100 - chatPercent()}%`, "min-width": "200px" };
176+
? { height: pct, "min-height": "120px" }
177+
: { width: pct, "min-width": "200px" };
169178
};
170179

171180
return (
@@ -268,6 +277,15 @@ export function App() {
268277
}
269278
.main-panel-body.dragging {
270279
user-select: none;
280+
cursor: col-resize;
281+
}
282+
.main-panel-body.dragging.vertical {
283+
cursor: row-resize;
284+
}
285+
.main-panel-body.dragging .main-panel-chat,
286+
.main-panel-body.dragging .main-panel-side {
287+
pointer-events: none;
288+
will-change: width, height;
271289
}
272290
.main-panel-chat {
273291
display: flex;

0 commit comments

Comments
 (0)