mirror of
https://github.com/futurepress/epub.js.git
synced 2025-10-03 14:59:18 +02:00
103 lines
2 KiB
HTML
103 lines
2 KiB
HTML
<!DOCTYPE html>
|
||
<html>
|
||
<head>
|
||
<meta charset="utf-8">
|
||
<title>EPUB.js Basic Example</title>
|
||
|
||
<script src="../dist/epub.js"></script>
|
||
|
||
<style type="text/css">
|
||
body {
|
||
margin: 0;
|
||
background: #fafafa;
|
||
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
|
||
color: #333;
|
||
}
|
||
|
||
#viewer {
|
||
width: 600px;
|
||
background: white;
|
||
box-shadow: 0 0 4px #ccc;
|
||
border-radius: 5px;
|
||
|
||
padding: 20px 40px;
|
||
/*width: 100%;*/
|
||
/* height: 400px;*/
|
||
position: relative;
|
||
margin: 100px auto;
|
||
}
|
||
|
||
|
||
#prev {
|
||
left: 40px;
|
||
}
|
||
|
||
#next {
|
||
right: 40px;
|
||
}
|
||
|
||
.arrow {
|
||
position: fixed;
|
||
top: 50%;
|
||
margin-top: -32px;
|
||
font-size: 64px;
|
||
color: #E2E2E2;
|
||
font-family: arial, sans-serif;
|
||
font-weight: bold;
|
||
cursor: pointer;
|
||
-webkit-user-select: none;
|
||
-moz-user-select: none;
|
||
user-select: none;
|
||
}
|
||
|
||
.arrow:hover {
|
||
color: #777;
|
||
}
|
||
|
||
.arrow:active {
|
||
color: #000;
|
||
}
|
||
|
||
#toc {
|
||
display: block;
|
||
margin: 10px auto;
|
||
}
|
||
|
||
</style>
|
||
</head>
|
||
<body>
|
||
<div id="viewer"></div>
|
||
<div id="prev" class="arrow">‹</div>
|
||
<div id="next" class="arrow">›</div>
|
||
<script>
|
||
var currentSectionIndex = 10;
|
||
// Load the opf
|
||
var book = ePub("https://s3.amazonaws.com/moby-dick/OPS/package.opf");
|
||
var rendition = book.renderTo("viewer", {axis: "horizontal", width: "100%", height: "100%", infinite: false});
|
||
|
||
var displayed = rendition.display(currentSectionIndex);
|
||
|
||
|
||
displayed.then(function(renderer){
|
||
// -- do stuff
|
||
});
|
||
|
||
// Navigation loaded
|
||
book.loaded.navigation.then(function(toc){
|
||
// console.log(toc);
|
||
});
|
||
|
||
var next = document.getElementById("next");
|
||
next.addEventListener("click", function(){
|
||
rendition.forwards()
|
||
}, false);
|
||
|
||
var prev = document.getElementById("prev");
|
||
prev.addEventListener("click", function(){
|
||
rendition.backgrounds()
|
||
}, false);
|
||
|
||
</script>
|
||
|
||
</body>
|
||
</html>
|