Commit b1583bba authored by Fred Chasen's avatar Fred Chasen

Fix chunker to handle sheets

parent 8ae9a0c8
Pipeline #193 failed with stage
in 3 minutes and 10 seconds
This diff is collapsed.
......@@ -362,7 +362,7 @@ class Chunker {
this.pages.push(page);
// Create the pages
page.create(undefined, lastPage && lastPage.element);
page.create(undefined, lastPage && lastPage.sheet);
page.index(this.total);
......@@ -425,7 +425,7 @@ class Chunker {
let total = this.pages.splice(index, 0, page);
// Create the pages
page.create(undefined, lastPage && lastPage.element);
page.create(undefined, lastPage && lastPage.sheet);
page.index(index + 1);
......
......@@ -24,16 +24,17 @@ class Page {
//let page = documentFragment.children[0];
let clone = document.importNode(this.pageTemplate.content, true);
let page;
let sheet, index;
if (after) {
this.pagesArea.insertBefore(clone, after.nextSibling);
let index = Array.prototype.indexOf.call(this.pagesArea.children, after.nextSibling);
page = this.pagesArea.children[index];
this.pagesArea.insertBefore(clone, after.nextElementSibling);
index = Array.prototype.indexOf.call(this.pagesArea.children, after.nextElementSibling);
sheet = this.pagesArea.children[index];
} else {
this.pagesArea.appendChild(clone);
page = this.pagesArea.lastChild;
sheet = this.pagesArea.lastChild;
}
let page = sheet.querySelector(".pagedjs_page");
let area = page.querySelector(".pagedjs_page_content");
......@@ -47,6 +48,7 @@ class Page {
this.width = Math.round(size.width);
this.height = Math.round(size.height);
this.sheet = sheet;
this.element = page;
this.area = area;
......@@ -66,13 +68,18 @@ class Page {
index(pgnum) {
this.position = pgnum;
let sheet = this.sheet;
let page = this.element;
let id = `page-${pgnum+1}`;
let index = pgnum+1;
let id = `page-${index}`;
this.id = id;
page.dataset.pageNumber = pgnum+1;
sheet.dataset.sheetNumber = index;
page.dataset.pageNumber = index;
page.setAttribute('id', id);
if (this.name) {
......
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