From dff2b040a0fc8c50e339ddc73a3b8bb29287134f Mon Sep 17 00:00:00 2001 From: "Sunil.Belakeri" Date: Tue, 7 Feb 2017 13:24:22 +0530 Subject: [PATCH 1/3] Fix for issues: https://github.com/futurepress/epub.js/issues/534 https://github.com/futurepress/epub.js/issues/528 --- src/managers/default/index.js | 5 +---- src/rendition.js | 2 +- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/src/managers/default/index.js b/src/managers/default/index.js index 6c5d4a3..cdd64dd 100644 --- a/src/managers/default/index.js +++ b/src/managers/default/index.js @@ -282,15 +282,12 @@ class DefaultViewManager { this.scrollBy(this.layout.delta, 0); } else if (left - this.layout.columnWidth === this.container.scrollWidth) { this.scrollTo(this.container.scrollWidth - this.layout.delta, 0); + next = this.views.last().section.next(); } else { next = this.views.last().section.next(); } - - } else { - next = this.views.last().section.next(); - } if(next) { diff --git a/src/rendition.js b/src/rendition.js index 0214a81..2e51a71 100644 --- a/src/rendition.js +++ b/src/rendition.js @@ -243,7 +243,7 @@ class Rendition { // removing the chapter if(!isCfiString && typeof target === "string" && target.indexOf("#") > -1) { - moveTo = target.substring(target.indexOf("#")+1); + moveTo = target; } if (isCfiString) { From c0533232d646faa031788c02575cb96aa8fdc28b Mon Sep 17 00:00:00 2001 From: "Sunil.Belakeri" Date: Tue, 7 Feb 2017 13:50:43 +0530 Subject: [PATCH 2/3] Fix for 528 --- src/contents.js | 6 ++---- src/rendition.js | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/contents.js b/src/contents.js index 6eba0b0..b061422 100644 --- a/src/contents.js +++ b/src/contents.js @@ -406,10 +406,8 @@ class Contents { } } - } else if(typeof target === "string" && - target.indexOf("#") > -1) { - - let id = target.substring(target.indexOf("#")+1); + } else if(typeof target === "string") { + let id = target; let el = this.document.getElementById(id); if(el) { diff --git a/src/rendition.js b/src/rendition.js index 2e51a71..0214a81 100644 --- a/src/rendition.js +++ b/src/rendition.js @@ -243,7 +243,7 @@ class Rendition { // removing the chapter if(!isCfiString && typeof target === "string" && target.indexOf("#") > -1) { - moveTo = target; + moveTo = target.substring(target.indexOf("#")+1); } if (isCfiString) { From 88fd89935d14bd82d9fd5fefacc28a2615191659 Mon Sep 17 00:00:00 2001 From: "Sunil.Belakeri" Date: Tue, 7 Feb 2017 14:08:31 +0530 Subject: [PATCH 3/3] Moved the logic of idenitfying fragment to content.js --- src/contents.js | 6 ++++-- src/rendition.js | 13 +------------ 2 files changed, 5 insertions(+), 14 deletions(-) diff --git a/src/contents.js b/src/contents.js index b061422..6eba0b0 100644 --- a/src/contents.js +++ b/src/contents.js @@ -406,8 +406,10 @@ class Contents { } } - } else if(typeof target === "string") { - let id = target; + } else if(typeof target === "string" && + target.indexOf("#") > -1) { + + let id = target.substring(target.indexOf("#")+1); let el = this.document.getElementById(id); if(el) { diff --git a/src/rendition.js b/src/rendition.js index 0214a81..560371b 100644 --- a/src/rendition.js +++ b/src/rendition.js @@ -239,18 +239,7 @@ class Rendition { return displayed; } - // Trim the target fragment - // removing the chapter - if(!isCfiString && typeof target === "string" && - target.indexOf("#") > -1) { - moveTo = target.substring(target.indexOf("#")+1); - } - - if (isCfiString) { - moveTo = target; - } - - return this.manager.display(section, moveTo) + return this.manager.display(section, target) .then(function(){ // this.emit("displayed", section); }.bind(this));