Skip to content

Commit ffa4ac1

Browse files
committed
Fixes #680 by adjusting canvas and iframe layout
- Set the preview canvas to `display:block` to remove vertical spacing caused by the default value, which was making a full-height canvas cause vertical scrolling, and the vertical scrollbar caused horizontal scrolling - Wrap the preview content in a container with `position:relative` and no other visible content, so that the full-height iframe excludes the height of the preview frame header, preventing it from going beyond the height of the page
1 parent 3b1cd67 commit ffa4ac1

File tree

4 files changed

+52
-34
lines changed

4 files changed

+52
-34
lines changed

client/modules/IDE/pages/IDEView.jsx

Lines changed: 36 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -370,41 +370,43 @@ class IDEView extends React.Component {
370370
<header className="preview-frame__header">
371371
<h2 className="preview-frame__title">Preview</h2>
372372
</header>
373-
<div className="preview-frame-overlay" ref={(element) => { this.overlay = element; }}>
373+
<div className="preview-frame__content">
374+
<div className="preview-frame-overlay" ref={(element) => { this.overlay = element; }}>
375+
</div>
376+
<div>
377+
{(
378+
(
379+
(this.props.preferences.textOutput ||
380+
this.props.preferences.gridOutput ||
381+
this.props.preferences.soundOutput
382+
) &&
383+
this.props.ide.isPlaying
384+
) ||
385+
this.props.ide.isAccessibleOutputPlaying
386+
)
387+
}
388+
</div>
389+
<PreviewFrame
390+
htmlFile={this.props.htmlFile}
391+
files={this.props.files}
392+
content={this.props.selectedFile.content}
393+
isPlaying={this.props.ide.isPlaying}
394+
isAccessibleOutputPlaying={this.props.ide.isAccessibleOutputPlaying}
395+
textOutput={this.props.preferences.textOutput}
396+
gridOutput={this.props.preferences.gridOutput}
397+
soundOutput={this.props.preferences.soundOutput}
398+
setTextOutput={this.props.setTextOutput}
399+
setGridOutput={this.props.setGridOutput}
400+
setSoundOutput={this.props.setSoundOutput}
401+
dispatchConsoleEvent={this.props.dispatchConsoleEvent}
402+
autorefresh={this.props.preferences.autorefresh}
403+
previewIsRefreshing={this.props.ide.previewIsRefreshing}
404+
endSketchRefresh={this.props.endSketchRefresh}
405+
stopSketch={this.props.stopSketch}
406+
setBlobUrl={this.props.setBlobUrl}
407+
expandConsole={this.props.expandConsole}
408+
/>
374409
</div>
375-
<div>
376-
{(
377-
(
378-
(this.props.preferences.textOutput ||
379-
this.props.preferences.gridOutput ||
380-
this.props.preferences.soundOutput
381-
) &&
382-
this.props.ide.isPlaying
383-
) ||
384-
this.props.ide.isAccessibleOutputPlaying
385-
)
386-
}
387-
</div>
388-
<PreviewFrame
389-
htmlFile={this.props.htmlFile}
390-
files={this.props.files}
391-
content={this.props.selectedFile.content}
392-
isPlaying={this.props.ide.isPlaying}
393-
isAccessibleOutputPlaying={this.props.ide.isAccessibleOutputPlaying}
394-
textOutput={this.props.preferences.textOutput}
395-
gridOutput={this.props.preferences.gridOutput}
396-
soundOutput={this.props.preferences.soundOutput}
397-
setTextOutput={this.props.setTextOutput}
398-
setGridOutput={this.props.setGridOutput}
399-
setSoundOutput={this.props.setSoundOutput}
400-
dispatchConsoleEvent={this.props.dispatchConsoleEvent}
401-
autorefresh={this.props.preferences.autorefresh}
402-
previewIsRefreshing={this.props.ide.previewIsRefreshing}
403-
endSketchRefresh={this.props.endSketchRefresh}
404-
stopSketch={this.props.stopSketch}
405-
setBlobUrl={this.props.setBlobUrl}
406-
expandConsole={this.props.expandConsole}
407-
/>
408410
</div>
409411
</SplitPane>
410412
</SplitPane>

client/modules/IDE/reducers/files.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ const defaultCSS =
3131
margin: 0;
3232
padding: 0;
3333
}
34+
canvas {
35+
display: block;
36+
}
3437
`;
3538

3639
const initialState = () => {

client/styles/components/_preview-frame.scss

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@
55
border-width: 0;
66
}
77

8+
.preview-frame-holder {
9+
display: flex;
10+
flex-direction: column;
11+
height: 100%;
12+
}
813

914
.preview-frame-overlay {
1015
height: 100%;
@@ -37,3 +42,8 @@
3742
font-size: #{12 / $base-font-size}rem;
3843
font-weight: normal;
3944
}
45+
46+
.preview-frame__content {
47+
position: relative;
48+
flex: 1 1 0;
49+
}

server/examples.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ const defaultCSS =
2828
margin: 0;
2929
padding: 0;
3030
}
31+
canvas {
32+
display: block;
33+
}
3134
`;
3235

3336
const clientId = process.env.GITHUB_ID;

0 commit comments

Comments
 (0)