diff --git a/test/demo/m2/README.md b/test/demo/m2/README.md index 881cfbdb..84028718 100644 --- a/test/demo/m2/README.md +++ b/test/demo/m2/README.md @@ -10,12 +10,10 @@ http://showcase.iiif.io/viewer/mirador/ ## To Do -* Detail images overlaid on the page * Cropped images ### Maybe -* Alternates: align with default image * Alternates: wait until tiles have loaded before switching * Show/hide pages? * Lazyloading tilesources? diff --git a/test/demo/m2/js/main.js b/test/demo/m2/js/main.js index e14dcb45..cf1e1a3f 100644 --- a/test/demo/m2/js/main.js +++ b/test/demo/m2/js/main.js @@ -11,7 +11,7 @@ this.mode = 'none'; this.pageBuffer = 0.05; this.bigBuffer = 0.2; - this.page = 0; + this.pageIndex = 0; this.modeNames = [ 'thumbs', 'scroll', @@ -22,7 +22,7 @@ this.pages = this.createPages(); var tileSources = $.map(this.pages, function(v, i) { - return v.tileSource; + return v.starter.tileSource; }); this.viewer = OpenSeadragon({ @@ -37,7 +37,8 @@ self.$el = $(self.viewer.element); $.each(self.pages, function(i, v) { - v.tiledImage = self.viewer.world.getItemAt(i); + v.setTiledImage(self.viewer.world.getItemAt(i)); + v.addDetails(); }); self.setMode({ @@ -50,7 +51,7 @@ if (self.mode === 'scroll') { var result = self.hitTest(self.viewer.viewport.getCenter()); if (result) { - self.page = result.index; + self.pageIndex = result.index; self.update(); } } @@ -116,7 +117,7 @@ if (result) { self.setMode({ mode: 'page', - page: result.index + pageIndex: result.index }); } }); @@ -155,40 +156,39 @@ // ---------- next: function() { - var page = this.page + (this.mode === 'book' ? 2 : 1); - if (this.mode === 'book' && page % 2 === 0 && page !== 0) { - page --; + var pageIndex = this.pageIndex + (this.mode === 'book' ? 2 : 1); + if (this.mode === 'book' && pageIndex % 2 === 0 && pageIndex !== 0) { + pageIndex --; } this.goToPage({ - page: page + pageIndex: pageIndex }); }, // ---------- previous: function() { - var page = this.page - (this.mode === 'book' ? 2 : 1); - if (this.mode === 'book' && page % 2 === 0 && page !== 0) { - page --; + var pageIndex = this.pageIndex - (this.mode === 'book' ? 2 : 1); + if (this.mode === 'book' && pageIndex % 2 === 0 && pageIndex !== 0) { + pageIndex --; } this.goToPage({ - page: page + pageIndex: pageIndex }); }, // ---------- hitTest: function(pos) { - var count = this.viewer.world.getItemCount(); - var item, box; + var count = this.pages.length; + var page, box; for (var i = 0; i < count; i++) { - item = this.viewer.world.getItemAt(i); - box = item.getBounds(); + page = this.pages[i]; + box = page.getBounds(); if (pos.x > box.x && pos.y > box.y && pos.x < box.x + box.width && pos.y < box.y + box.height) { return { - item: item, index: i }; } @@ -222,8 +222,8 @@ var self = this; $('.nav').toggle(this.mode === 'scroll' || this.mode === 'book' || this.mode === 'page'); - $('.previous').toggleClass('hidden', this.page <= 0); - $('.next').toggleClass('hidden', this.page >= this.viewer.world.getItemCount() - 1); + $('.previous').toggleClass('hidden', this.pageIndex <= 0); + $('.next').toggleClass('hidden', this.pageIndex >= this.pages.length - 1); $.each(this.modeNames, function(i, v) { $('.' + v).toggleClass('active', v === self.mode); @@ -235,7 +235,7 @@ this.$alternates = null; } - var page = this.pages[this.page]; + var page = this.pages[this.pageIndex]; if (page && page.alternates && page.alternates.length) { this.$alternates = $('