I recently ran into a problem/maybe bug with cw-prints where if I had a 3 page book (seems to happen with odd page books) I would get an error thrown at me when I hit the last page:
Uncaught TypeError: Cannot read properties of null (reading 'classList') (@cw-prints/html/script.js:51)
I already solved this, I wanted to post and if its a good solution maybe it could get added. I appreciate the script a great bit. My proposed solution is this:
replace lines 50 and 51:
this.classList.add('flipped');
this.nextElementSibling.classList.add('flipped');
With:
if (this.pageNum !== pages.length){
this.classList.add('flipped');
if (this.nextElementSibling)
this.nextElementSibling.classList.add('flipped');
}
I'm not the greatest at javascript, but to my knowledge this basically makes it so that if its the last page it can't be flipped any further to prevent the last page turn from clumping when you "get to the end"
I'm interested to know if this is happening because I'm dumb or if this is a genuine solution to problem. I appreciate the script and I already recommended it to a server that adopted it which is why I'm doing this debugging
Hope its ok to post this here, I wasn't sure where else to post it
