File tree Expand file tree Collapse file tree 2 files changed +20
-1
lines changed
Expand file tree Collapse file tree 2 files changed +20
-1
lines changed Original file line number Diff line number Diff line change 278278 * @name viewer
279279 * @property {array } volumes Volumes to be displayed.
280280 * @property {boolean } synced Are the cursors being synced across volumes?
281+ * @property {array } containers The div containers for each volume.
281282 * @property {DOMElement } dom_element The DOM element where the viewer
282283 * will be inserted.
283284 * @property {active_panel } active_panel The slice panel that's currently
316317 var viewer = {
317318 dom_element : dom_element ,
318319 volumes : [ ] ,
320+ containers : [ ] ,
319321 synced : false
320322 } ;
321323
Original file line number Diff line number Diff line change @@ -291,6 +291,7 @@ BrainBrowser.VolumeViewer.modules.loading = function(viewer) {
291291 } ) ;
292292
293293 viewer . volumes = [ ] ;
294+ viewer . containers = [ ] ;
294295 viewer . active_panel = null ;
295296 viewer . dom_element . innerHTML = "" ;
296297 } ;
@@ -719,7 +720,23 @@ BrainBrowser.VolumeViewer.modules.loading = function(viewer) {
719720 } ) ;
720721 } ) ( ) ;
721722
722- dom_element . appendChild ( container ) ;
723+ viewer . containers [ vol_id ] = container ;
724+
725+ /* See if a subsequent volume has already been loaded. If so we want
726+ * to be sure that this container is inserted before the subsequent
727+ * container. This guarantees the ordering of elements.
728+ */
729+ var containers = viewer . containers ;
730+ var next_id ;
731+ for ( next_id = vol_id + 1 ; next_id < containers . length ; next_id ++ ) {
732+ if ( next_id in containers ) {
733+ dom_element . insertBefore ( container , containers [ next_id ] ) ;
734+ break ;
735+ }
736+ }
737+ if ( next_id === containers . length ) {
738+ dom_element . appendChild ( container ) ;
739+ }
723740 viewer . triggerEvent ( "volumeuiloaded" , {
724741 container : container ,
725742 volume : volume ,
You can’t perform that action at this time.
0 commit comments