Created
January 2, 2020 15:04
-
-
Save julientaq/5cf14efea3dc96f7cfc4191642cf71cf to your computer and use it in GitHub Desktop.
add one blank page if the total number of pages is odd in paged.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
class pairPage extends Paged.Handler { | |
constructor(chunker, polisher, caller) { | |
super(chunker, polisher, caller); | |
} | |
afterRendered(pages) { | |
if (pages.length % 2 === 1) { | |
const pageNew = document.createElement("div"); | |
pageNew.classList.add("pagedjs_page"); | |
document.querySelector('.pagedjs_pages').insertAdjacentElement("beforeend", pageNew); | |
console.log( document.querySelector('.pagedjs_pages')); | |
} | |
} | |
} | |
Paged.registerHandlers(pairPage); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment