Skip to content

Commit

Permalink
Merge pull request #1550 from Jennief/issue-1549-Book-View-incorrect-…
Browse files Browse the repository at this point in the history
…for-R-to-L-manuscripts

Patch for issue 1549. Book View incorrect for R-to-L Manuscripts.
  • Loading branch information
mejackreed authored Jan 10, 2019
2 parents deffb29 + 8450524 commit 0406537
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 10 deletions.
19 changes: 13 additions & 6 deletions js/src/widgets/bookView.js
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,7 @@
rightIndex = [],
topIndex = [],
bottomIndex = [],
viewAdjustedImgIndex = this.currentImgIndex,
_this = this;

this.focusImages = [];
Expand All @@ -418,20 +419,26 @@
// don't do any stitching, display like an imageView
stitchList = [this.currentImg];
} else if (this.viewingHint === 'paged') {

// For RTL work out index from right hand side.
if (this.viewingDirection === 'right-to-left') {
viewAdjustedImgIndex = (this.imagesList.length-1) - this.currentImgIndex;
}

// determine the other image for this pair based on index and viewingDirection
if (this.currentImgIndex === 0 || this.currentImgIndex === this.imagesList.length-1) {
if (viewAdjustedImgIndex === 0 || viewAdjustedImgIndex === this.imagesList.length-1) {
//first page (front cover) or last page (back cover), display on its own
stitchList = [this.currentImg];
} else if (this.currentImgIndex % 2 === 0) {
} else if (viewAdjustedImgIndex % 2 === 0) {
// even, get previous page. set order in array based on viewingDirection
switch (this.viewingDirection) {
case "left-to-right":
leftIndex[0] = this.currentImgIndex-1;
stitchList = [this.imagesList[this.currentImgIndex-1], this.currentImg];
break;
case "right-to-left":
rightIndex[0] = this.currentImgIndex-1;
stitchList = [this.currentImg, this.imagesList[this.currentImgIndex-1]];
rightIndex[0] = this.currentImgIndex+1;
stitchList = [this.currentImg, this.imagesList[this.currentImgIndex+1]];
break;
case "top-to-bottom":
topIndex[0] = this.currentImgIndex-1;
Expand All @@ -452,8 +459,8 @@
stitchList = [this.currentImg, this.imagesList[this.currentImgIndex+1]];
break;
case "right-to-left":
leftIndex[0] = this.currentImgIndex+1;
stitchList = [this.imagesList[this.currentImgIndex+1], this.currentImg];
leftIndex[0] = this.currentImgIndex-1;
stitchList = [this.imagesList[this.currentImgIndex-1], this.currentImg];
break;
case "top-to-bottom":
bottomIndex[0] = this.currentImgIndex+1;
Expand Down
6 changes: 4 additions & 2 deletions js/src/workspaces/window.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,10 @@

_this.removeBookView();

this.viewingDirection = _this.manifest.getViewingDirection();
//reset imagemodes and then remove any imageModes that are not available as a focus
//add getting rtl value
if(_this.manifest.getViewingDirection() == 'right-to-left'){
if(this.viewingDirection == 'right-to-left'){
_this.vDirectionStatus = 'rtl';
}
else{
Expand Down Expand Up @@ -551,7 +552,7 @@
imagesList: _this.imagesList,
imagesListLtr: _this.imagesListLtr,
imagesListRtl: _this.imagesListRtl,
vDirectionStatus: _this.vDirectionStatus,
vDirectionStatus: _this.vDirectionStatus,
thumbInfo: {thumbsHeight: 80, listingCssCls: 'panel-listing-thumbs', thumbnailCls: 'panel-thumbnail-view'}
});
}
Expand Down Expand Up @@ -802,6 +803,7 @@
imagesListRtl: this.imagesListRtl,
imagesListLtr: this.imagesListLtr,
vDirectionStatus: this.vDirectionStatus,
viewingDirection: this.viewingDirection,
osdOptions: this.windowOptions,
bottomPanelAvailable: this.bottomPanelAvailable
});
Expand Down
4 changes: 2 additions & 2 deletions spec/widgets/bookView.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ describe('BookView', function() {
});
it('stitches right-to-left', function() {
subject.viewingDirection = 'right-to-left';
expect(subject.getStitchList()).toEqual([this.imagesList[4], this.imagesList[3]]);
expect(subject.getStitchList()).toEqual([this.imagesList[3], this.imagesList[4]]);
});
it('stitches top-down', function() {
subject.viewingDirection = 'top-to-bottom';
Expand All @@ -533,7 +533,7 @@ describe('BookView', function() {
});
it('stitches right-to-left', function() {
subject.viewingDirection = 'right-to-left';
expect(subject.getStitchList()).toEqual([this.imagesList[6], this.imagesList[5]]);
expect(subject.getStitchList()).toEqual([this.imagesList[5], this.imagesList[6]]);
});
it('stitches top-down', function() {
subject.viewingDirection = 'top-to-bottom';
Expand Down

0 comments on commit 0406537

Please sign in to comment.