diff --git a/test/demo/m2/README.md b/test/demo/m2/README.md index ceffed8f..f76745b3 100644 --- a/test/demo/m2/README.md +++ b/test/demo/m2/README.md @@ -1,7 +1,7 @@ # To Do -* Scroll view: go to current page when entering mode; clamp at first and last - +* Next/previous in scroll mode +* Detect which page you're on in scroll mode (when switching to other modes) * Constraints * Thumbs: no zoom, no pan * Scroll: can't zoom out much, can't pan up and down @@ -9,3 +9,4 @@ * Resize on window resize * When going to thumbs, scroll to the proper part of the page * Show/hide pages? +* Arrow keys diff --git a/test/demo/m2/js/main.js b/test/demo/m2/js/main.js index 2a9e50af..43499dc1 100644 --- a/test/demo/m2/js/main.js +++ b/test/demo/m2/js/main.js @@ -195,6 +195,8 @@ this.page = page; + var viewerWidth = this.$el.width(); + var viewerHeight = this.$el.height(); var bounds = this.viewer.world.getItemAt(this.page).getBounds(); var x = bounds.x; var y = bounds.y; @@ -222,6 +224,17 @@ y -= this.pageBuffer; width += (this.pageBuffer * 2); height += (this.pageBuffer * 2); + + if (this.mode === 'scroll') { + if (this.page === 0) { + x = -this.pageBuffer; + width = height * (viewerWidth / viewerHeight); + } else if (this.page === this.viewer.world.getItemCount() - 1) { + width = height * (viewerWidth / viewerHeight); + x = (bounds.x + bounds.width + this.pageBuffer) - width; + } + } + this.viewer.viewport.fitBounds(new OpenSeadragon.Rect(x, y, width, height)); this.update();