@@ -173,7 +173,7 @@ const rgbToHex = (color) => {
173173 this . app = new Application ( { width : this . props . width , height : this . props . height } ) ;
174174 // this.app.renderer.backgroundColor = '#1a1a1a';
175175 // maintain full window size
176- this . refs . stackCanvas ?. getElementsByTagName ( "canvas" ) ?. length == 0 && this . refs . stackCanvas ?. appendChild ( this . app . view ) ;
176+ this . stackCanvas ?. getElementsByTagName ( "canvas" ) ?. length == 0 && this . stackCanvas ?. appendChild ( this . app . view ) ;
177177
178178 this . disp = new Container ( { width : this . props . width , height : this . props . height } ) ;
179179 this . disp . pivot . x = 0 ;
@@ -243,8 +243,8 @@ const rgbToHex = (color) => {
243243 this . lastWindowHeight = window . innerHeight ;
244244
245245 // Create bound methods for proper cleanup
246- this . boundHandleWindowResize = this . handleWindowResize . bind ( this ) ;
247- this . boundHandleVisualViewportChange = this . handleVisualViewportChange . bind ( this ) ;
246+ this . boundHandleWindowResize = this . handleWindowResize ;
247+ this . boundHandleVisualViewportChange = this . handleVisualViewportChange ;
248248
249249 // Listen for window resize events (covers most zoom scenarios)
250250 window . addEventListener ( 'resize' , this . boundHandleWindowResize ) ;
@@ -255,7 +255,7 @@ const rgbToHex = (color) => {
255255 }
256256
257257 // Setup ResizeObserver for the canvas container if available
258- if ( window . ResizeObserver && this . refs . stackCanvas ) {
258+ if ( window . ResizeObserver && this . stackCanvas ) {
259259 this . resizeObserver = new ResizeObserver ( ( ) => {
260260 if ( ! this . _isMounted ) return ;
261261
@@ -268,13 +268,13 @@ const rgbToHex = (color) => {
268268 }
269269 } ) ;
270270
271- this . resizeObserver . observe ( this . refs . stackCanvas ) ;
271+ this . resizeObserver . observe ( this . stackCanvas ) ;
272272 }
273273
274274 // Fallback: Listen for devicePixelRatio changes (Webkit-based browsers)
275275 if ( window . matchMedia ) {
276276 this . mediaQueryList = window . matchMedia ( `(resolution: ${ window . devicePixelRatio } dppx)` ) ;
277- this . boundHandleDevicePixelRatioChange = this . handleDevicePixelRatioChange . bind ( this ) ;
277+ this . boundHandleDevicePixelRatioChange = this . handleDevicePixelRatioChange ;
278278 this . mediaQueryList . addListener ( this . boundHandleDevicePixelRatioChange ) ;
279279 }
280280
@@ -343,7 +343,7 @@ const rgbToHex = (color) => {
343343 // Properly cleanup PIXI application and WebGL context
344344 if ( this . app ) {
345345 // Remove canvas from DOM
346- if ( this . refs . stackCanvas && this . app . view && this . app . view . parentNode ) {
346+ if ( this . stackCanvas && this . app . view && this . app . view . parentNode ) {
347347 this . app . view . parentNode . removeChild ( this . app . view ) ;
348348 }
349349
@@ -494,7 +494,9 @@ const rgbToHex = (color) => {
494494 let extent = { imageX : imageX , imageY : imageY } ;
495495 that . setState ( extent ) ;
496496 that . props . setExtent ( extent ) ;
497- that . onResize ( that . props . width , that . props . height ) ;
497+ if ( typeof that . onResize === 'function' ) {
498+ that . onResize ( that . props . width , that . props . height ) ;
499+ }
498500 that . checkStack ( ) ;
499501 that . callPlaneEdges ( ) ;
500502 that . state . iBuffer = { } ;
@@ -1519,7 +1521,7 @@ const rgbToHex = (color) => {
15191521 */
15201522 render : function ( ) {
15211523 return (
1522- < div className = "stack-canvas-container" ref = " stackCanvas" > </ div >
1524+ < div className = "stack-canvas-container" ref = { ( el ) => { this . stackCanvas = el ; } } > </ div >
15231525 ) ;
15241526 } ,
15251527
@@ -2251,7 +2253,7 @@ const StackViewerComponent = () => createClass({
22512253 }
22522254
22532255 return < ReactResizeDetector skipOnMount = { true } onResize = { this . onResize } >
2254- < div id = 'slice-viewer' style = { { width : '100%' , height : '100%' } } ref = { this . refs . stackCanvas } >
2256+ < div id = 'slice-viewer' style = { { width : '100%' , height : '100%' } } >
22552257 { markup }
22562258 </ div >
22572259 </ ReactResizeDetector >
0 commit comments