Skip to content

Commit 660d67c

Browse files
committed
removed scroll up and down from code preview
1 parent 6755973 commit 660d67c

File tree

1 file changed

+22
-29
lines changed

1 file changed

+22
-29
lines changed

app/src/components/main/CanvasContainer.tsx

Lines changed: 22 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -88,16 +88,8 @@ function CanvasContainer(props: CanvasContainerProps): JSX.Element {
8888
state.components[0].children.length > 0 &&
8989
components.scrollHeight == components.clientHeight
9090
) {
91-
console.log('if components scroll height', components.scrollHeight);
92-
console.log('if components client height', components.clientHeight);
93-
console.log('if container scroll height', container.scrollHeight);
94-
console.log('if container client height', container.clientHeight);
9591
container.scrollTop = 0;
9692
} else if (container && components) {
97-
console.log('else components scroll height', components.scrollHeight);
98-
console.log('else components client height', components.clientHeight);
99-
console.log('else container scroll height', container.scrollHeight);
100-
console.log('else container client height', container.clientHeight);
10193
container.scrollTop = container.scrollHeight;
10294
}
10395
}, [state.components[0].children.length, zoom]);
@@ -126,40 +118,41 @@ function CanvasContainer(props: CanvasContainerProps): JSX.Element {
126118
<Button style={codePreviewStyle} onClick={onClickCodePreview}>
127119
Code Preview
128120
</Button>
129-
<div>
130-
<Button
131-
style={backToTop}
132-
onClick={() => {
133-
container.scrollTop = 0;
134-
}}
135-
>
136-
Scroll Top
137-
</Button>
138-
<Button
139-
style={backToTop}
140-
onClick={() => {
141-
container.scrollTop = container.clientHeight;
142-
}}
143-
>
144-
Scroll Bottom
145-
</Button>
146-
</div>
121+
{!state.codePreview && (
122+
<div>
123+
<Button
124+
style={backToTop}
125+
onClick={() => {
126+
container.scrollTop = 0;
127+
}}
128+
>
129+
Scroll Top
130+
</Button>
131+
<Button
132+
style={backToTop}
133+
onClick={() => {
134+
container.scrollTop = container.clientHeight;
135+
}}
136+
>
137+
Scroll Bottom
138+
</Button>
139+
</div>
140+
)}
147141
<Button style={buttonStyle} onClick={zoomIn}>
148142
<ZoomIn />
149143
</Button>
150144
<Button style={buttonStyle} onClick={zoomOut}>
151145
<ZoomOut />
152146
</Button>
153147
</div>
154-
{state.codePreview && (
148+
{state.codePreview ? (
155149
<CodePreview
156150
theme={theme}
157151
setTheme={setTheme}
158152
zoom={zoom}
159153
containerRef={containerRef}
160154
/>
161-
)}
162-
{!state.codePreview && (
155+
) : (
163156
<Canvas
164157
zoom={zoom}
165158
ref={containerRef} /*isThemeLight={props.isThemeLight} */

0 commit comments

Comments
 (0)