#3 Page Book Issue

1 messages · Page 1 of 1 (latest)

magic rapids
#

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

limpid heron
#

Neat. Thanks for the fix chilidog
Will put it into the public repo when I've had time to try it

magic rapids
# limpid heron Neat. Thanks for the fix <:chilidog:1042531278785872013> Will put it into the p...

Thanks! I also made a little snippet thing that I added to it where the idea is people from the config file can add targetable zones which open up books in order to place business menus around the world. It's basically just following the item format and sending it to open book or open card

I can dm/post that snippet as well if you'd like! It's just not very framework agnostic because I just needed it for oxtarget and qb