Skip to content

Commit 96dbf2e

Browse files
committed
refactor: pass root
1 parent e5d03ec commit 96dbf2e

2 files changed

Lines changed: 7 additions & 8 deletions

File tree

packages/instrument-library/src/interactive/breakout-task/index.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,11 @@ function getScale() {
2525
return ratios.at(-1)!;
2626
}
2727

28-
function runTask(onComplete: (data: Data) => void) {
28+
function runTask(root: HTMLDivElement, onComplete: (data: Data) => void) {
2929
const startTime = Date.now();
3030
const ratio = window.devicePixelRatio * 3;
3131
const scale = getScale();
3232

33-
const wrapper = document.createElement('div');
34-
wrapper.classList.add('canvas-wrapper');
35-
3633
const canvas = document.createElement('canvas');
3734

3835
const height = BASE_HEIGHT * scale;
@@ -43,8 +40,7 @@ function runTask(onComplete: (data: Data) => void) {
4340
canvas.style.width = width + 'px';
4441
canvas.style.height = height + 'px';
4542

46-
wrapper.appendChild(canvas);
47-
document.body.appendChild(wrapper);
43+
root.appendChild(canvas);
4844

4945
const ctx = canvas.getContext('2d')!;
5046
ctx.scale(ratio, ratio);
@@ -229,7 +225,10 @@ export default defineInstrument({
229225
},
230226
content: {
231227
render(done) {
232-
runTask(done);
228+
const root = document.createElement('div');
229+
root.id = 'root';
230+
document.body.appendChild(root);
231+
runTask(root, done);
233232
}
234233
},
235234
details: {

packages/instrument-library/src/interactive/breakout-task/styles.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ canvas {
99
margin: 0 auto;
1010
}
1111

12-
.canvas-wrapper {
12+
#root {
1313
display: flex;
1414
justify-content: center;
1515
align-items: center;

0 commit comments

Comments
 (0)