diff --git a/test/demo/collections/main.js b/test/demo/collections/main.js index 03547079..9eeb757c 100644 --- a/test/demo/collections/main.js +++ b/test/demo/collections/main.js @@ -14,8 +14,30 @@ prefixUrl: "../../../build/openseadragon/images/" } ); + this.gridTest(); + }, + + // ---------- + crossTest: function() { + var self = this; + this.viewer.addHandler( "open", function() { - self.addLayer(); + var options = { + tileSource: '../../data/wide.dzi', + opacity: 1, + x: 0, + y: 1.5, + height: 1 + }; + + var addItemHandler = function( event ) { + if ( event.options === options ) { + self.viewer.world.removeHandler( "add-item", addItemHandler ); + self.viewer.viewport.goHome(); + } + }; + self.viewer.world.addHandler( "add-item", addItemHandler ); + self.viewer.addTiledImage( options ); }); this.viewer.open("../../data/tall.dzi", { @@ -26,25 +48,45 @@ }, // ---------- - addLayer: function() { + gridTest: function() { var self = this; + var startX = -3; + var expected = 0; + var loaded = 0; - var options = { - tileSource: '../../data/wide.dzi', - opacity: 1, - x: 0, - y: 1.5, - height: 1 - }; + this.viewer.addHandler( "open", function() { + self.viewer.world.addHandler('add-item', function() { + loaded++; + if (loaded === expected) { + self.viewer.viewport.goHome(); + } + }); - var addLayerHandler = function( event ) { - if ( event.options === options ) { - self.viewer.removeHandler( "add-layer", addLayerHandler ); - self.viewer.viewport.goHome(); + var x, y; + for (y = 0; y < 6; y++) { + for (x = 0; x < 6; x++) { + if (!x && !y) { + continue; + } + + var options = { + tileSource: '../../data/testpattern.dzi', + x: startX + x, + y: y, + width: 1 + }; + + expected++; + self.viewer.addTiledImage( options ); + } } - }; - this.viewer.addHandler( "add-layer", addLayerHandler ); - this.viewer.addLayer( options ); + }); + + this.viewer.open("../../data/testpattern.dzi", { + x: startX, + y: 0, + width: 1 + }); } };