File tree Expand file tree Collapse file tree
packages/instrument-library/src/interactive/breakout-task Expand file tree Collapse file tree Original file line number Diff line number Diff 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 : {
Original file line number Diff line number Diff line change 99 margin : 0 auto;
1010}
1111
12- . canvas-wrapper {
12+ # root {
1313 display : flex;
1414 justify-content : center;
1515 align-items : center;
You can’t perform that action at this time.
0 commit comments