summaryrefslogtreecommitdiff
path: root/lib/epub.js/examples/continuous-scrolled.html
blob: 3d8a63ce167074e352a8597586885175c99f55ee (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>EPUB.js Continuous Example</title>

  <script src="../dist/epub.js"></script>

  <link rel="stylesheet" type="text/css" href="examples.css">

  <style type="text/css">

    .epub-container {
      /* min-width: 320px; */
      /* margin: 0 auto; */
      /* position: relative; */
    }

    .epub-container .epub-view > iframe {
        background: white;
        box-shadow: 0 0 4px #ccc;
        /*margin: 10px;
        padding: 20px;*/
    }

    #viewer {
      width: 600px;
      height: 100vh;
      /* overflow: auto; */
      margin: 0 auto;
    }

  </style>
</head>
<body>
  <div id="viewer"></div>

  <script>
    var params = URLSearchParams && new URLSearchParams(document.location.search.substring(1));
    var url = params && params.get("url") && decodeURIComponent(params.get("url"));
    var currentSectionIndex = (params && params.get("loc")) ? params.get("loc") : undefined;

    // Load the opf
    var book = ePub(url || "https://s3.amazonaws.com/epubjs/books/moby-dick/OPS/package.opf");
    var rendition = book.renderTo("viewer", {
        manager: "continuous",
        flow: "scrolled",
        width: "100%",
        height: "100%"
      });
    var displayed = rendition.display(currentSectionIndex);


    displayed.then(function(renderer){
      // -- do stuff
    });

    // Navigation loaded
    book.loaded.navigation.then(function(toc){
      // console.log(toc);
    });


  </script>

</body>
</html>