Cloud Defense Logo

Products

Solutions

Company

Book A Live Demo

Top 10 Examples of "epubjs in functional component" in JavaScript

Dive into secure and efficient coding practices with our curated list of the top 10 examples showcasing 'epubjs' in functional components in JavaScript. Our advanced machine learning engine meticulously scans each line of code, cross-referencing millions of open source libraries to ensure your implementation is not just functional, but also robust and secure. Elevate your React applications to new heights by mastering the art of handling side effects, API calls, and asynchronous operations with confidence and precision.

prepend(section) {
    var displaying = new core.defer();
    let sections = [section];

    // if (this.scrolling) {
    //   // queue
    //   console.log("queue");
    //   return;
    // }
    if (this.state.sections.includes(section)) {
      return;
    }

    if (this.fixed && this.spreads) {
      let prevSection = section.prev();
      prevSection && sections.unshift(prevSection);
    }
expand() {
    var width, height;
    var expanded;
    var expanding;
    __DEV__ && console.log("expanding", this.index);
    // if (this.expanding || this.loading) {
    //   return;
    // }
    this.expanding = true;

    if (this.props.layout.name === "pre-paginated") {
      // this.expanding = false;
        var defered = new core.defer();
        let width = this.props.columnWidth;
        let marginLeft = 0;

        if (this.props.spreads && this.props.section.index === 0) {
          width = this.props.columnWidth * 2;
          marginLeft = this.props.columnWidth;
        }

        if (this.props.spreads &&
            this.props.section.index === this.props.lastSectionIndex &&
            this.props.section.index % 2 > 0 ) {
          width = this.props.columnWidth * 2;
        }

        this.setState({
          width,
load() {
    var loaded = new core.defer();

    if (!this.sectionRendering) {
      this.sectionRendering = this.props.section.render(this.props.request);
    }

    // console.log("loading", this.props.section.index);

    if (!this.state.contents) {
      this.sectionRendering.then((contents) => {
          if (!this.mounted) {
            return; // Prevent updating an unmounted component
          }
          this.setState({ contents }, () => {

            this.rendering.resolve();
            loaded.resolve();
}).then((h) => {
        var defered = new core.defer();
        var margin = 0;

        height = h;
        // console.log("Height", height);

        this.setState({ height, margin }, () => {
          this.expanding = false;
          defered.resolve();
        });

        return defered.promise;
      });
    }
append(section) {
    var displaying = new core.defer();
    let sections = [section];

    if (this.state.sections.includes(section)) {
      return;
    }

    if (this.fixed && this.spreads) {
      let nextSection = section.next();
      nextSection && sections.push(nextSection);
    }

    // __DEV__ && console.log("append", section.index);

    this.setState({
        sections: this.state.sections.concat(sections),
      },
handleReadyRendition() {
        this.updateRenditionTheme(this.themeStyle);

        this.rendition.on(EVENTS.RENDITION.RELOCATED, location => this.relocatedHandler(location));
        this.rendition.on('keyup', this.handleKeyUps);
        this.rendition.on('click', () => this.closeSideBar());

        window.addEventListener('mousedown', this.handleMouseDown, { passive: true });

        this.loaded = true;

        this.book.locations.generate(LOCATIONS_INTERVAL).then(locations => {
          this.locations = locations;
          this.$emit('startTracking');
          this.updateContentStateInterval = setInterval(this.updateProgress, 30000);

          // Update current location, .currentLocation() can return Promise or value
          Promise.resolve()
            .then(() => this.rendition.currentLocation())
            .then(currentLocation => {
showEpub() {
      // 生成Book对象
      this.book = new Epub(DOWNLOAD_URL)
      // 通过Book.renderTo生成Rendition对象
      this.rendition = this.book.renderTo('read', {
        width: window.innerWidth,
        height: window.innerHeight,
        // 兼容iOS
        method: 'default'
      })
      // 通过Rendtion.display渲染电子书
      this.rendition.display()
      // 获取Theme对象
      this.themes = this.rendition.themes
      // 设置默认字体
      this.setFontSize(this.defaultFontSize)
      // 注册主题
      this.registerTheme()
      // 设置默认主题
function getInfo(filePath, callback) {
  // parameter validation
  if (!filePath || typeof filePath !== 'string') {
    return;
  }

  // create a key from path
  const key = genrateKey(filePath);

  // file load on file protocol
  const uri = fileUrl(filePath);
  const book = new Book(uri);

  book.ready
    .then(() => {
      return book.locations.generate();
    })
    .then(locations => {
      const meta = book.package.metadata;

      const info = {
        id: key,
        title: meta.title,
        author: meta.creator,
        publisher: meta.publisher,
        path: uri,
        bookmarks: [],
        highlights: [],
_loadBook(bookUrl) {
    __DEV__ && console.log("loading book: ", bookUrl);

    this.book = ePub({
      replacements: this.props.base64 || "none"
    });

    return this._openBook(bookUrl);

    /*
    var type = this.book.determineType(bookUrl);

    var uri = new Uri(bookUrl);
    if ((type === "directory") || (type === "opf")) {
      return this._openBook(bookUrl);
    } else {
      return this.streamer.start()
      .then((localOrigin) => {
        this.setState({localOrigin})
        return this.streamer.get(bookUrl);
viewport: () => this.ask("viewport"),
      addStylesheet: (src) => this.ask("addStylesheet", [src]),
      addStylesheetRules: (rules) => this.ask("addStylesheetRules", [rules]),
      addScript: (src) => this.ask("addScript", [src]),
      range: (_cfi, ignoreClass) => this.ask("addStylesheet", [_cfi, ignoreClass]),
      map: (map) => this.ask("map", [map]),
      columns: (width, height, columnWidth, gap) => this.ask("columns", [width, height, columnWidth, gap]),
      fit: (width, height) => this.ask("fit", [width, height]),
      size: (width, height) => this.ask("size", [width, height]),
      mapPage: (cfiBase, start, end) => this.ask("mapPage", [cfiBase, start, end]),
      locationOf: (target) => this.ask("locationOf", [target]),
    }

    EventEmitter(this.contents);

    this.rendering = new core.defer();
    this.rendered = this.rendering.promise;

    this.loading = true;
    this.expanded = false;
  }

Is your System Free of Underlying Vulnerabilities?
Find Out Now