Commit 80a8fb48 authored by Guillaume's avatar Guillaume

Remove the wrapper to avoid layout issue

In fact, the wrapping `<div>` does not fit the whole page and prevents the root element of a page to take 100% of the page height.

resolves #162
parent 29482f92
Pipeline #669 passed with stage
in 4 minutes and 10 seconds
...@@ -339,7 +339,7 @@ class Chunker { ...@@ -339,7 +339,7 @@ class Chunker {
await this.hooks.afterPageLayout.trigger(page.element, page, breakToken, this); await this.hooks.afterPageLayout.trigger(page.element, page, breakToken, this);
this.emit("renderedPage", page); this.emit("renderedPage", page);
this.recoredCharLength(page.wrapper.textContent.length); this.recoredCharLength(page.area.textContent.length);
yield breakToken; yield breakToken;
......
...@@ -55,16 +55,6 @@ class Page { ...@@ -55,16 +55,6 @@ class Page {
return page; return page;
} }
createWrapper() {
let wrapper = document.createElement("div");
this.area.appendChild(wrapper);
this.wrapper = wrapper;
return wrapper;
}
index(pgnum) { index(pgnum) {
this.position = pgnum; this.position = pgnum;
...@@ -125,8 +115,8 @@ class Page { ...@@ -125,8 +115,8 @@ class Page {
this.layoutMethod = new Layout(this.area, this.hooks, maxChars); this.layoutMethod = new Layout(this.area, this.hooks, maxChars);
let newBreakToken = await this.layoutMethod.renderTo(this.wrapper, contents, breakToken); let newBreakToken = await this.layoutMethod.renderTo(this.area, contents, breakToken);
this.addListeners(contents); this.addListeners(contents);
this.endToken = newBreakToken; this.endToken = newBreakToken;
...@@ -140,7 +130,7 @@ class Page { ...@@ -140,7 +130,7 @@ class Page {
return this.layout(contents, breakToken); return this.layout(contents, breakToken);
} }
let newBreakToken = await this.layoutMethod.renderTo(this.wrapper, contents, breakToken); let newBreakToken = await this.layoutMethod.renderTo(this.area, contents, breakToken);
this.endToken = newBreakToken; this.endToken = newBreakToken;
...@@ -167,8 +157,11 @@ class Page { ...@@ -167,8 +157,11 @@ class Page {
clear() { clear() {
this.removeListeners(); this.removeListeners();
this.wrapper && this.wrapper.remove(); const node = this.area;
this.createWrapper(); // clear content
while (node.firstChild) {
node.firstChild.remove();
}
} }
addListeners(contents) { addListeners(contents) {
...@@ -210,7 +203,7 @@ class Page { ...@@ -210,7 +203,7 @@ class Page {
} }
addResizeObserver(contents) { addResizeObserver(contents) {
let wrapper = this.wrapper; let wrapper = this.area;
let prevHeight = wrapper.getBoundingClientRect().height; let prevHeight = wrapper.getBoundingClientRect().height;
this.ro = new ResizeObserver(entries => { this.ro = new ResizeObserver(entries => {
...@@ -240,7 +233,7 @@ class Page { ...@@ -240,7 +233,7 @@ class Page {
return; return;
} }
let newBreakToken = this.layoutMethod.findBreakToken(this.wrapper, contents, this.startToken); let newBreakToken = this.layoutMethod.findBreakToken(this.area, contents, this.startToken);
if (newBreakToken) { if (newBreakToken) {
this.endToken = newBreakToken; this.endToken = newBreakToken;
...@@ -253,7 +246,7 @@ class Page { ...@@ -253,7 +246,7 @@ class Page {
return; return;
} }
let endToken = this.layoutMethod.findEndToken(this.wrapper, contents); let endToken = this.layoutMethod.findEndToken(this.area, contents);
if (endToken) { if (endToken) {
this._onUnderflow && this._onUnderflow(endToken); this._onUnderflow && this._onUnderflow(endToken);
...@@ -267,7 +260,6 @@ class Page { ...@@ -267,7 +260,6 @@ class Page {
this.element.remove(); this.element.remove();
this.element = undefined; this.element = undefined;
this.wrapper = undefined;
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment