From b7bb95d97ab05f8269b9e74dd997a519ad0138d9 Mon Sep 17 00:00:00 2001 From: Meng-Yuan Huang Date: Sat, 5 Sep 2020 21:37:23 +0800 Subject: [PATCH 1/9] * Fix moveTo for vertical writing mode. --- src/managers/default/index.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/managers/default/index.js b/src/managers/default/index.js index 1944889ad..dc80f7f15 100644 --- a/src/managers/default/index.js +++ b/src/managers/default/index.js @@ -343,6 +343,12 @@ class DefaultViewManager { if (distX + this.layout.delta > this.container.scrollWidth) { distX = this.container.scrollWidth - this.layout.delta; } + + distY = Math.floor(offset.top / this.layout.delta) * this.layout.delta; + + if (distY + this.layout.delta > this.container.scrollHeight) { + distY = this.container.scrollHeight - this.layout.delta; + } } this.scrollTo(distX, distY, true); } From c59226133c6c8b87ac755dba9c58e609c6168f9d Mon Sep 17 00:00:00 2001 From: Meng-Yuan Huang Date: Sun, 6 Sep 2020 21:31:09 +0800 Subject: [PATCH 2/9] * Fix a layout update bug after crossing a section boundary. --- src/managers/default/index.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/managers/default/index.js b/src/managers/default/index.js index dc80f7f15..a1ee60d94 100644 --- a/src/managers/default/index.js +++ b/src/managers/default/index.js @@ -492,6 +492,8 @@ class DefaultViewManager { if(next) { this.clear(); + // The new section may have a different writing-mode from the old section. Thus, we need to update layout. + this.updateLayout(); let forceRight = false; if (this.layout.name === "pre-paginated" && this.layout.divisor === 2 && next.properties.includes("page-spread-right")) { @@ -583,6 +585,8 @@ class DefaultViewManager { if(prev) { this.clear(); + // The new section may have a different writing-mode from the old section. Thus, we need to update layout. + this.updateLayout(); let forceRight = false; if (this.layout.name === "pre-paginated" && this.layout.divisor === 2 && typeof prev.prev() !== "object") { From 86f7370cab411baa60b5c1d8e951f08b7ee8faa2 Mon Sep 17 00:00:00 2001 From: Meng-Yuan Huang Date: Sun, 6 Sep 2020 21:33:48 +0800 Subject: [PATCH 3/9] * Update version. --- package.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 76b2d8c56..960afd402 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { - "name": "epubjs", - "version": "0.3.88", + "name": "epubjs-myh", + "version": "0.3.89", "description": "Parse and Render Epubs", "main": "lib/index.js", "module": "src/index.js", @@ -24,7 +24,7 @@ "watch": "babel --watch -d lib/ src/", "prepare": "npm run compile && npm run build && npm run minify && npm run legacy && npm run productionLegacy" }, - "author": "fchasen@gmail.com", + "author": "myh@live.com", "license": "BSD-2-Clause", "devDependencies": { "@babel/cli": "^7.10.1", From c48d34c339469aaec681562a38b7338ea8b501a2 Mon Sep 17 00:00:00 2001 From: Meng-Yuan Huang Date: Wed, 16 Sep 2020 15:40:23 +0800 Subject: [PATCH 4/9] * Update version. --- package.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 960afd402..1ba103cab 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "epubjs-myh", - "version": "0.3.89", + "version": "0.3.90", "description": "Parse and Render Epubs", "main": "lib/index.js", "module": "src/index.js", @@ -16,10 +16,10 @@ "docs:md": "documentation build src/epub.js -f md -o documentation/md/API.md", "lint": "eslint -c .eslintrc.js src; exit 0", "start": "webpack-dev-server --inline --d", - "build": "NODE_ENV=production webpack --progress", - "minify": "NODE_ENV=production MINIMIZE=true webpack --progress", - "legacy": "NODE_ENV=production LEGACY=true webpack --progress", - "productionLegacy": "NODE_ENV=production MINIMIZE=true LEGACY=true webpack --progress", + "build": "set NODE_ENV=production && webpack --progress", + "minify": "set NODE_ENV=production && set MINIMIZE=true && webpack --progress", + "legacy": "set NODE_ENV=production && set LEGACY=true && webpack --progress", + "productionLegacy": "set NODE_ENV=production && set MINIMIZE=true && set LEGACY=true && webpack --progress", "compile": "babel -d lib/ src/", "watch": "babel --watch -d lib/ src/", "prepare": "npm run compile && npm run build && npm run minify && npm run legacy && npm run productionLegacy" From 84c020adf13e73fbe6293227379170eaf8d425e9 Mon Sep 17 00:00:00 2001 From: Roger Huang Date: Wed, 16 Sep 2020 16:40:43 +0800 Subject: [PATCH 5/9] * Fix top and bottom gap calculations for vertical writing mode. --- src/layout.js | 4 ++-- src/managers/default/index.js | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/layout.js b/src/layout.js index 4f16a0f1d..24ad20b86 100644 --- a/src/layout.js +++ b/src/layout.js @@ -100,7 +100,7 @@ class Layout { * @param {number} _height height of the rendering * @param {number} _gap width of the gap between columns */ - calculate(_width, _height, _gap){ + calculate(_width, _height, _gap, axis){ var divisor = 1; var gap = _gap || 0; @@ -110,7 +110,7 @@ class Layout { var width = _width; var height = _height; - var section = Math.floor(width / 12); + var section = Math.floor((axis === 'vertical' ? height : width) / 12); var columnWidth; var spreadWidth; diff --git a/src/managers/default/index.js b/src/managers/default/index.js index a1ee60d94..26f5795cf 100644 --- a/src/managers/default/index.js +++ b/src/managers/default/index.js @@ -930,12 +930,13 @@ class DefaultViewManager { this._stageSize = this.stage.size(); if(!this.isPaginated) { - this.layout.calculate(this._stageSize.width, this._stageSize.height); + this.layout.calculate(this._stageSize.width, this._stageSize.height, undefined, this.settings.axis); } else { this.layout.calculate( this._stageSize.width, this._stageSize.height, - this.settings.gap + this.settings.gap, + this.settings.axis ); // Set the look ahead offset for what is visible From 92d93c460381f8d2b8d6e00a925e8ce3bf5d7f13 Mon Sep 17 00:00:00 2001 From: Roger Huang Date: Wed, 16 Sep 2020 16:44:12 +0800 Subject: [PATCH 6/9] * Update version. --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 1ba103cab..0a68303b1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "epubjs-myh", - "version": "0.3.90", + "version": "0.3.92", "description": "Parse and Render Epubs", "main": "lib/index.js", "module": "src/index.js", From 8fbbd7ee5766525560146553122514dd0d7df6ea Mon Sep 17 00:00:00 2001 From: Roger Huang Date: Thu, 17 Sep 2020 22:15:23 +0800 Subject: [PATCH 7/9] * Fix a gap update bug after scrolling from one section to another section with different writing modes. --- src/managers/default/index.js | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/managers/default/index.js b/src/managers/default/index.js index 26f5795cf..e9cecf12b 100644 --- a/src/managers/default/index.js +++ b/src/managers/default/index.js @@ -457,7 +457,7 @@ class DefaultViewManager { this.scrollLeft = this.container.scrollLeft; if (this.settings.rtlScrollType === "default"){ - left = this.container.scrollLeft; + left = Math.floor(this.container.scrollLeft); if (left > 0) { this.scrollBy(this.layout.delta, 0, true); @@ -492,8 +492,6 @@ class DefaultViewManager { if(next) { this.clear(); - // The new section may have a different writing-mode from the old section. Thus, we need to update layout. - this.updateLayout(); let forceRight = false; if (this.layout.name === "pre-paginated" && this.layout.divisor === 2 && next.properties.includes("page-spread-right")) { @@ -585,8 +583,6 @@ class DefaultViewManager { if(prev) { this.clear(); - // The new section may have a different writing-mode from the old section. Thus, we need to update layout. - this.updateLayout(); let forceRight = false; if (this.layout.name === "pre-paginated" && this.layout.divisor === 2 && typeof prev.prev() !== "object") { @@ -998,6 +994,7 @@ class DefaultViewManager { this.layout.spread(this.layout.settings.spread); } } + this.updateLayout(); } updateFlow(flow, defaultScrolledOverflow="auto"){ From 7e4f7b7ffce3eba55e974766302829a2d0eac817 Mon Sep 17 00:00:00 2001 From: Roger Huang Date: Thu, 17 Sep 2020 22:25:49 +0800 Subject: [PATCH 8/9] * Update version. --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 0a68303b1..bffc8e138 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "epubjs-myh", - "version": "0.3.92", + "version": "0.3.93", "description": "Parse and Render Epubs", "main": "lib/index.js", "module": "src/index.js", From 9baec61247cffc6fc4a71b1ccac00417e4535529 Mon Sep 17 00:00:00 2001 From: Roger Huang Date: Fri, 18 Sep 2020 10:56:31 +0800 Subject: [PATCH 9/9] * Fix page navigations for some layout modes. --- src/managers/default/index.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/managers/default/index.js b/src/managers/default/index.js index e9cecf12b..a11aa67b5 100644 --- a/src/managers/default/index.js +++ b/src/managers/default/index.js @@ -457,6 +457,8 @@ class DefaultViewManager { this.scrollLeft = this.container.scrollLeft; if (this.settings.rtlScrollType === "default"){ + this.scrollLeft = Math.floor(this.container.scrollLeft); + // this.container.scrollLeft could has fractional part. left = Math.floor(this.container.scrollLeft); if (left > 0) { @@ -492,6 +494,7 @@ class DefaultViewManager { if(next) { this.clear(); + this.updateLayout(); let forceRight = false; if (this.layout.name === "pre-paginated" && this.layout.divisor === 2 && next.properties.includes("page-spread-right")) { @@ -565,9 +568,10 @@ class DefaultViewManager { } else if (this.isPaginated && this.settings.axis === "vertical") { - this.scrollTop = this.container.scrollTop; + this.scrollTop = Math.floor(this.container.scrollTop); - let top = this.container.scrollTop; + // this.container.scrollTop could has fractional part. + let top = Math.floor(this.container.scrollTop); if(top > 0) { this.scrollBy(0, -(this.layout.height), true); @@ -583,6 +587,7 @@ class DefaultViewManager { if(prev) { this.clear(); + this.updateLayout(); let forceRight = false; if (this.layout.name === "pre-paginated" && this.layout.divisor === 2 && typeof prev.prev() !== "object") { @@ -994,7 +999,6 @@ class DefaultViewManager { this.layout.spread(this.layout.settings.spread); } } - this.updateLayout(); } updateFlow(flow, defaultScrolledOverflow="auto"){