diff --git a/js/src/widgets/bookView.js b/js/src/widgets/bookView.js index f72df6da27bf0deb5c3bea8903891ac6896a1f25..8b67917dc759f496be2a6ce67248ad0f16dd638b 100755 --- a/js/src/widgets/bookView.js +++ b/js/src/widgets/bookView.js @@ -410,6 +410,7 @@ rightIndex = [], topIndex = [], bottomIndex = [], + viewAdjustedImgIndex = this.currentImgIndex, _this = this; this.focusImages = []; @@ -418,11 +419,17 @@ // 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": @@ -430,8 +437,8 @@ 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; @@ -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; diff --git a/js/src/workspaces/window.js b/js/src/workspaces/window.js index 518c36eeee99d327b995f17cc692fda26298014b..9f531f294eb479b1848d29e8f05f6115ca888d99 100644 --- a/js/src/workspaces/window.js +++ b/js/src/workspaces/window.js @@ -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{ @@ -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'} }); } @@ -802,6 +803,7 @@ imagesListRtl: this.imagesListRtl, imagesListLtr: this.imagesListLtr, vDirectionStatus: this.vDirectionStatus, + viewingDirection: this.viewingDirection, osdOptions: this.windowOptions, bottomPanelAvailable: this.bottomPanelAvailable }); diff --git a/spec/widgets/bookView.test.js b/spec/widgets/bookView.test.js index f4898f38e763146df8b60b29000966f980db4457..3e4026e3dc3572b689ec6ca17e184c07192a0336 100644 --- a/spec/widgets/bookView.test.js +++ b/spec/widgets/bookView.test.js @@ -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'; @@ -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';