How to use the epubjs.Rendition function in epubjs

To help you get started, we’ve selected a few epubjs examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Janglee123 / eplee / src / renderer / views / Reader.vue View on Github external
const { id } = this.$route.params;
    this.info = this.$db.get(id);
    this.toc = this.info.toc;
    this.info.lastOpen = new Date().getTime();
    this.buble = this.$refs.bubleMenu
    this.book = new Book(this.info.path);

    this._flattenedToc = (function flatten(items) {
      return [].concat(...items.map(item => [item].concat(...flatten(item.children))));
    })(this.toc);

    this._flattenedToc.sort((a,b)=>{
      return a.percentage - b.percentage;
    })

    this.rendition = new Rendition(this.book, {
      width: '100%',
      height: '100%',
    });

    this.rendition.on('rendered', (e, iframe) => {
      clickListener(iframe.document, this.rendition, this.flipPage);
      selectListener(iframe.document, this.rendition, this.toggleBuble);
      swipListener(iframe.document,  this.flipPage);
      wheelListener(iframe.document, this.flipPage);
      keyListener(iframe.document, this.flipPage);
    });

    this.rendition.on('relocated', location => {
      this.info.lastCfi = location.start.cfi;
      this.$db.set(this.info.id, this.info);
      this.history.push(location.start.cfi);