Skip to content

Commit

Permalink
fix(App): fix ?view=result when loading external content
Browse files Browse the repository at this point in the history
  • Loading branch information
hatemhosny committed Apr 14, 2024
1 parent 3c64de5 commit 1314202
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/livecodes/UI/split-panes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,16 @@ export const createSplitPanes = (layout: 'vertical' | 'horizontal' = 'horizontal
}
};

const show = (pane: 'code' | 'output', full?: boolean) => {
const show = (pane: 'code' | 'output' | 'toggle', full?: boolean) => {
if (!split) init();
const smallScreen = layout === 'horizontal' && window.innerWidth < 800;
const codeOpen = full || (smallScreen && full !== false) ? [100, 0] : [50, 50];
const outputOpen = full || (smallScreen && full !== false) ? [0, 100] : [50, 50];
if (pane === 'code' && (split.getSizes()[0] < 10 || full)) {
split.setSizes(codeOpen);
} else if (pane === 'output' && (split.getSizes()[1] < 10 || full)) {
split.setSizes(outputOpen);
} else if (pane === 'toggle' && (split.getSizes()[1] < 10 || full)) {
if (split.getSizes()[0] < 10) {
// toggle result
split.setSizes(codeOpen);
Expand Down
2 changes: 1 addition & 1 deletion src/livecodes/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2170,7 +2170,7 @@ const handleRunButton = () => {
};

const handleResultButton = () => {
eventsManager.addEventListener(UI.getResultButton(), 'click', () => split?.show('output', true));
eventsManager.addEventListener(UI.getResultButton(), 'click', () => split?.show('toggle', true));
};

const handleShareButton = () => {
Expand Down

0 comments on commit 1314202

Please sign in to comment.