epub.js icon indicating copy to clipboard operation
epub.js copied to clipboard

Setting the theme and then changing it back will not update

Open tp1415926535 opened this issue 3 years ago • 6 comments

I found a strange problem, when I use epub.js ( v0.3.88 ) to set theme and then changing it back will not update, but if I use the unknow version js download from example and set theme twice, it works good. But I can't make my project use that version of js directly, because it will make the page display nothing. Here's the situation what I found in the release version js: I registered two theme like these rendition.themes.register("light",{ "body": { "background-color": "#FFFFFF", "color": "#000000" }, }); rendition.themes.register("dark",{ "body": { "background-color": "#111111", "color": "#D9D9D9" }, }); I called rendition.themes.select("light");, it worked. then rendition.themes.select("dark");, it worked, then rendition.themes.select("light");, it doesn't worked.

tp1415926535 avatar Jul 18 '21 15:07 tp1415926535

I have same issue. Did you have the solution for this?

hungnguyentiki avatar Sep 05 '21 15:09 hungnguyentiki

I have same issue. Did you have the solution for this?

I made it work at the cost of a noticeable page reload by adding two lines of code like this :

    rendition.themes.select(value);
    try {
      rendition.clear();
      rendition.start();
    }
    catch{ }

Obviously it's not a best solution, so I still hope the author can fix this problem.

tp1415926535 avatar Oct 27 '21 08:10 tp1415926535

seems like this hack doesn't work either

ddo avatar Mar 01 '22 16:03 ddo

I've had this happen on my Aura One on stock software, even on very recent versions (<1 month ago)

PeeJeeDR avatar Oct 03 '22 21:10 PeeJeeDR

I have the same issue. I'm using React Reader v1.2.1 which depends on epubjs v0.3.93. The themes object in rendition looks normal to me to reflect current selected theme. Not sure what's preventing it from getting rendered properly.

ryuzio avatar Apr 01 '23 08:04 ryuzio

Using CSS is not affected

    bookDeal.rendition.themes.register('light', "bookThemes.css");
    bookDeal.rendition.themes.register('dark', "bookThemes.css");
    bookDeal.rendition.themes.register('tan', "bookThemes.css");

css:

.light {
  background: #fff;
  color: #000;
}
.dark {
  background: #232323;
  color: #fff;
}
.tan {
  background: tan;
  color: #ccc;
}

epcwxa avatar Sep 19 '23 06:09 epcwxa