Fix sidebar

This commit is contained in:
space-nuko
2023-04-07 06:30:21 -05:00
parent b0c5e938b8
commit e62994aa86
2 changed files with 24 additions and 27 deletions

View File

@@ -12,9 +12,11 @@
let app: ComfyApp = undefined; let app: ComfyApp = undefined;
let uiPane: ComfyUIPane = undefined; let uiPane: ComfyUIPane = undefined;
let containerElem: HTMLDivElement; let containerElem: HTMLDivElement;
let resizeTimeout: typeof Timer = -1;
function refreshView(event) { function refreshView(event) {
app.resizeCanvas(); clearTimeout(resizeTimeout);
resizeTimeout = setTimeout(app.resizeCanvas.bind(app), 250);
} }
function queuePrompt() { function queuePrompt() {
@@ -35,10 +37,6 @@
} }
} }
function testtr() {
console.warn("TESTTR!")
}
let graphResizeTimer: typeof Timer = -1; let graphResizeTimer: typeof Timer = -1;
onMount(async () => { onMount(async () => {
@@ -54,7 +52,7 @@
(window as any).app = app; (window as any).app = app;
let graphPaneDiv = containerElem.querySelector("canvas").parentNode as HTMLDivNode; let graphPaneDiv = containerElem.querySelector(".canvas-wrapper").parentNode as HTMLDivNode;
graphPaneDiv.ontransitionend = () => { graphPaneDiv.ontransitionend = () => {
app.resizeCanvas() app.resizeCanvas()
} }
@@ -64,21 +62,23 @@
<div id="dropzone" class="dropzone"></div> <div id="dropzone" class="dropzone"></div>
<div id="container" bind:this={containerElem}> <div id="container" bind:this={containerElem}>
<Splitpanes theme="comfy" on:resize={refreshView}> <Splitpanes theme="comfy" on:resize={refreshView}>
<Pane size={20} minSize={10}>
<div>
Sidebar
</div>
</Pane>
<Pane> <Pane>
<Splitpanes theme="comfy" on:resize={refreshView} horizontal="{true}"> <Splitpanes theme="comfy" on:resize={refreshView} horizontal="{true}">
<Pane minSize={15}> <Pane minSize={15}>
<ComfyUIPane bind:this={uiPane} {app} /> <ComfyUIPane bind:this={uiPane} {app} />
</Pane> </Pane>
<Pane snapSize={10} bind:size={graphSize}> <Pane snapSize={10} bind:size={graphSize}>
<div class="canvas-wrapper">
<canvas id="graph-canvas" /> <canvas id="graph-canvas" />
</div>
</Pane> </Pane>
</Splitpanes> </Splitpanes>
</Pane> </Pane>
<Pane size={20} snapSize={10}>
<div>
Sidebar
</div>
</Pane>
</Splitpanes> </Splitpanes>
</div> </div>
<div id="bottombar"> <div id="bottombar">
@@ -93,6 +93,7 @@
<style> <style>
#container { #container {
height: calc(100vh - 60px); height: calc(100vh - 60px);
max-width: 100vw;
display: grid; display: grid;
width: 100%; width: 100%;
} }
@@ -109,14 +110,18 @@
} }
#graph-canvas { #graph-canvas {
width: 100%;
height: 100%;
} }
#bottombar { #bottombar {
margin: 10px; margin: 10px;
} }
.canvas-wrapper {
width: 100%;
height: 100%;
background-color: #333;
}
.dropzone { .dropzone {
box-sizing: border-box; box-sizing: border-box;
display: none; display: none;
@@ -149,6 +154,7 @@
:global(.splitpanes.comfy) { :global(.splitpanes.comfy) {
max-height: calc(100vh - 60px); max-height: calc(100vh - 60px);
max-width: 100vw;
} }
:global(.splitpanes__pane) { :global(.splitpanes__pane) {

View File

@@ -108,19 +108,10 @@ export default class ComfyApp {
} }
resizeCanvas() { resizeCanvas() {
// get current size of the canvas this.canvasEl.width = this.canvasEl.parentElement.offsetWidth;
let rect = this.canvasEl.parentElement.getBoundingClientRect(); this.canvasEl.height = this.canvasEl.parentElement.offsetHeight;
this.canvasEl.style.width = ""
// increase the actual size of our canvas this.canvasEl.style.height = ""
this.canvasEl.width = rect.width * window.devicePixelRatio;
this.canvasEl.height = rect.height * window.devicePixelRatio;
// ensure all drawing operations are scaled
this.canvasCtx.scale(window.devicePixelRatio, window.devicePixelRatio);
// scale everything down using CSS
this.canvasEl.style.width = rect.width + 'px';
this.canvasEl.style.height = rect.height + 'px';
this.lCanvas.draw(true, true); this.lCanvas.draw(true, true);
} }