@@ -981,16 +981,14 @@ const rgbToHex = (color) => {
981981 createImages : async function ( ) {
982982 if ( this . state . stack . length > 0 ) {
983983 var i , x , y , w , h , d , offX , offY , t , image , Xpos , Ypos , XboundMax , YboundMax , XboundMin , YboundMin ;
984- /*
985- * move through tiles
986- * console.log('Creating slice view...');
987- */
984+
988985 this . state . visibleTiles = [ ] ;
989- w = Math . ceil ( ( ( this . state . imageX / 10.0 ) * this . state . scl ) / this . state . tileX ) ;
990- h = Math . ceil ( ( ( this . state . imageY / 10.0 ) * this . state . scl ) / this . state . tileY ) ;
991- // console.log('Tile grid is ' + w.toString() + ' wide by ' + h.toString() + ' high' );
986+
987+ w = Math . ceil ( this . state . imageX / this . state . tileX ) ;
988+ h = Math . ceil ( this . state . imageY / this . state . tileY ) ;
992989 this . state . numTiles = w * h ;
993-
990+ // console.log('Tile grid is ' + w.toString() + ' wide by ' + h.toString() + ' high');
991+
994992 for ( t = 0 ; t < w * h ; t ++ ) {
995993 x = 0 ;
996994 y = 0 ;
@@ -1683,12 +1681,23 @@ const StackViewerComponent = () => createClass({
16831681 }
16841682
16851683 // detect available wheel event
1686- support = "onwheel" in document . createElement ( "div" ) ? "wheel" // Modern browsers support "wheel"
1687- : document . onmousewheel !== undefined ? "mousewheel" // Webkit and IE support at least "mousewheel"
1688- : "DOMMouseScroll" ; // let's assume that remaining browsers are older Firefox
1689- this ?. addWheelListener ( document . getElementById ( this . props . data . id + 'displayArea' ) , ( e ) => {
1684+ support = "onwheel" in document . createElement ( "div" )
1685+ ? "wheel" // Modern browsers
1686+ : document . onmousewheel !== undefined
1687+ ? "mousewheel" // Webkit / IE
1688+ : "DOMMouseScroll" ; // Older Firefox
1689+
1690+ const displayElem =
1691+ document . getElementById ( ( this . props . data && this . props . data . id ) + 'displayArea' ) ||
1692+ document . getElementById ( 'slice-viewer' ) ;
1693+
1694+ if ( displayElem ) {
1695+ this . addWheelListener ( displayElem , ( e ) => {
16901696 this . onWheelEvent ( e ) ;
16911697 } ) ;
1698+ } else {
1699+ console . warn ( 'StackViewer: wheel listener target not found for slice viewer' ) ;
1700+ }
16921701
16931702 if ( this . props . data && this . props . data != null && this . props . data . instances && this . props . data . instances != null ) {
16941703 this . setState ( this . handleInstances ( this . props . data . instances ) ) ;
@@ -1732,24 +1741,30 @@ const StackViewerComponent = () => createClass({
17321741 newState . voxelY = Number ( this . props . config . subDomains [ 0 ] [ 1 ] || 0.622088 ) ;
17331742 newState . voxelZ = Number ( this . props . config . subDomains [ 0 ] [ 2 ] || 0.622088 ) ;
17341743 }
1735- if ( this . props . config && this . props . config != null ) {
1736- if ( this . props . config . subDomains && this . props . config . subDomains != null && this . props . config . subDomains . length ) {
1737- if ( this . props . config . subDomains . length > 0 && this . props . config . subDomains [ 0 ] && this . props . config . subDomains [ 0 ] . length && this . props . config . subDomains [ 0 ] . length > 2 ) {
1738- newState . voxelX = Number ( this . props . config . subDomains [ 0 ] [ 0 ] || 0.622088 ) ;
1739- newState . voxelY = Number ( this . props . config . subDomains [ 0 ] [ 1 ] || 0.622088 ) ;
1740- newState . voxelZ = Number ( this . props . config . subDomains [ 0 ] [ 2 ] || 0.622088 ) ;
1741- }
1742- if ( this . props . config . subDomains . length > 3 && this . props . config . subDomains [ 1 ] != null ) {
1743- newState . tempName = this . props . config . subDomains [ 2 ] ;
1744- newState . tempId = this . props . config . subDomains [ 1 ] ;
1745- newState . tempType = this . props . config . subDomains [ 3 ] ;
1746- // FIXME : Add extra subdomain to match previous configuration
1747- // if (this.props.config.subDomains[4] && this.props.config.subDomains[4].length && this.props.config.subDomains[4].length > 0) {
1748- // newState.fxp = JSON.parse(this.props.config.subDomains[4][0]);
1749- // }
1750- }
1744+ if ( this . props . config ) {
1745+ const {
1746+ subDomains = [ ] ,
1747+ templateDomainIds,
1748+ templateDomainNames,
1749+ templateDomainTypeIds
1750+ } = this . props . config ;
1751+
1752+ if ( subDomains . length > 0 && subDomains [ 0 ] && subDomains [ 0 ] . length > 2 ) {
1753+ newState . voxelX = Number ( subDomains [ 0 ] [ 0 ] || 0.622088 ) ;
1754+ newState . voxelY = Number ( subDomains [ 0 ] [ 1 ] || 0.622088 ) ;
1755+ newState . voxelZ = Number ( subDomains [ 0 ] [ 2 ] || 0.622088 ) ;
17511756 }
1752- }
1757+
1758+ const templateIds = templateDomainIds || subDomains [ 1 ] ;
1759+ const templateNames = templateDomainNames || subDomains [ 2 ] ;
1760+ const templateTypes = templateDomainTypeIds || subDomains [ 3 ] ;
1761+
1762+ if ( templateIds && templateNames && templateTypes ) {
1763+ newState . tempId = templateIds ;
1764+ newState . tempName = templateNames ;
1765+ newState . tempType = templateTypes ;
1766+ }
1767+ }
17531768 for ( instance in instances ) {
17541769 try {
17551770 if ( ( instances [ instance ] . wrappedObj . id != undefined ) && ( instances [ instance ] . parent != null ) ) {
@@ -1792,7 +1807,7 @@ const StackViewerComponent = () => createClass({
17921807
17931808 componentWillUnmount : function ( ) {
17941809 this . _isMounted = false ;
1795- return true ;
1810+ return true ;
17961811 } ,
17971812 /**
17981813 * Event handler for clicking zoom in. Increments the zoom level
0 commit comments