* Scroll view: go to current page when entering mode; clamp at first and last (m2)

This commit is contained in:
Ian Gilman 2015-01-09 14:04:45 -08:00
parent 70e461c214
commit a470d10f4d
2 changed files with 16 additions and 2 deletions

View File

@ -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

View File

@ -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();