File tree Expand file tree Collapse file tree 2 files changed +13
-13
lines changed
Expand file tree Collapse file tree 2 files changed +13
-13
lines changed Original file line number Diff line number Diff line change @@ -262,6 +262,10 @@ export default class AnimationManager extends EventListener {
262262 this . addListener ( 'AnimationEnded' , this , this . animEnded ) ;
263263 this . addListener ( 'AnimationWaiting' , this , this . animWaiting ) ;
264264 this . addListener ( 'AnimationUndoUnavailable' , this , this . animUndoUnavailable ) ;
265+
266+ // TODO: invistagate why 0 ms causes extra 3 pixels to be added to height
267+ setTimeout ( ( ) => {
268+ this . updateDimensions ( ) } , 10 )
265269 }
266270
267271 lerp ( from , to , percent ) {
@@ -318,6 +322,12 @@ export default class AnimationManager extends EventListener {
318322 this . fireEvent ( 'CanvasSizeChanged' , { width : canvas . width , height : canvas . height } ) ;
319323 }
320324
325+ updateDimensions ( ) {
326+ canvas . height = 100 ;
327+ canvas . width = 50 ;
328+ this . changeSize ( document . getElementById ( "canvasContainer" ) . clientWidth - 1 , document . getElementById ( "canvasContainer" ) . clientHeight - 1 ) ;
329+ } ;
330+
321331 startNextBlock ( ) {
322332 this . awaitingStep = false ;
323333 this . currentBlock = [ ] ;
Original file line number Diff line number Diff line change @@ -55,20 +55,10 @@ const AlgoScreen = ({ theme, toggleTheme }) => {
5555 }
5656 }
5757
58- const updateDimensions = ( ) => {
59- canvasRef . current . height = 100 ;
60- canvasRef . current . width = 50 ;
61- animManagRef . current . changeSize ( document . getElementById ( "canvasContainer" ) . clientWidth - 1 , document . getElementById ( "canvasContainer" ) . clientHeight - 1 ) ;
62- } ;
63-
64-
65- window . addEventListener ( 'resize' , updateDimensions ) ;
66-
67- // TODO: invistagate why 0 ms causes extra 3 pixels to be added to height
68- setTimeout ( updateDimensions , 10 )
69-
58+ const updateDimensionsRef = canvasRef . current . updateDimensions ;
59+ window . addEventListener ( 'resize' , updateDimensionsRef ) ;
7060 return ( ) => {
71- window . removeEventListener ( 'resize' , updateDimensions ) ;
61+ window . removeEventListener ( 'resize' , updateDimensionsRef ) ;
7262 } ;
7363 }
7464 } , [ algoName , algoDetails , searchParams ] ) ;
You can’t perform that action at this time.
0 commit comments