mirror of
https://github.com/futurepress/epub.js.git
synced 2025-10-04 15:09:16 +02:00
basic scrolling renderer
This commit is contained in:
parent
849625fc83
commit
b1b98f9d57
15 changed files with 1020 additions and 22 deletions
127
examples/basic-render.html
Normal file
127
examples/basic-render.html
Normal file
|
@ -0,0 +1,127 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>EPUB.js Basic Example</title>
|
||||
|
||||
<script src="../bower_components/rsvp/rsvp.js"></script>
|
||||
|
||||
<script src="../lib/epub.js"></script>
|
||||
<script src="../lib/epubjs/core.js"></script>
|
||||
<script src="../lib/epubjs/hooks.js"></script>
|
||||
<script src="../lib/epubjs/book.js"></script>
|
||||
<script src="../lib/epubjs/parser.js"></script>
|
||||
<script src="../lib/epubjs/spine.js"></script>
|
||||
<script src="../lib/epubjs/navigation.js"></script>
|
||||
<script src="../lib/epubjs/epubcfi.js"></script>
|
||||
<script src="../lib/epubjs/renderer.js"></script>
|
||||
<script src="../lib/epubjs/view.js"></script>
|
||||
<script src="../lib/epubjs/infinite.js"></script>
|
||||
|
||||
<style type="text/css">
|
||||
body {
|
||||
margin: 0;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
#viewer {
|
||||
display: block;
|
||||
margin: 5% auto;
|
||||
width: 80%;
|
||||
height: 80%;
|
||||
border: none;
|
||||
}
|
||||
|
||||
#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>
|
||||
<!-- <select id="toc"></select> -->
|
||||
<!-- <iframe id="viewer"></iframe> -->
|
||||
<div id="viewer"></div>
|
||||
<div id="prev" class="arrow">‹</div>
|
||||
<div id="next" class="arrow">›</div>
|
||||
|
||||
<script>
|
||||
var $viewer = document.getElementById("viewer");
|
||||
var $next = document.getElementById("next");
|
||||
var $prev = document.getElementById("prev");
|
||||
var currentSection;
|
||||
var currentSectionIndex = 0;
|
||||
|
||||
var book = ePub("../books/moby-dick/OPS/package.opf");
|
||||
var rendition = book.renderTo("viewer");
|
||||
rendition.display(currentSectionIndex);
|
||||
|
||||
// Navigations Drop Down
|
||||
book.loaded.navigation.then(function(toc){
|
||||
var $select = document.getElementById("toc"),
|
||||
docfrag = document.createDocumentFragment();
|
||||
|
||||
toc.forEach(function(chapter) {
|
||||
var option = document.createElement("option");
|
||||
option.textContent = chapter.label;
|
||||
option.ref = chapter.href;
|
||||
|
||||
docfrag.appendChild(option);
|
||||
});
|
||||
|
||||
// $select.appendChild(docfrag);
|
||||
|
||||
// $select.onchange = function(){
|
||||
// var index = $select.selectedIndex;
|
||||
// var url = $select.options[index].ref;
|
||||
// rendition.display(url);
|
||||
// return false;
|
||||
// };
|
||||
|
||||
$next.addEventListener("click", function(){
|
||||
rendition.display(currentSectionIndex+1);
|
||||
currentSectionIndex++;
|
||||
}, false);
|
||||
|
||||
$prev.addEventListener("click", function(){
|
||||
rendition.display(currentSectionIndex-1);
|
||||
currentSectionIndex--;
|
||||
}, false);
|
||||
|
||||
|
||||
});
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
Loading…
Add table
Add a link
Reference in a new issue