mirror of
https://github.com/futurepress/epub.js.git
synced 2025-10-04 15:09:16 +02:00
Fixes to examples, and lint errors per pr #230 (by pmstss)
This commit is contained in:
parent
2e2d7dfb43
commit
d7371a619d
9 changed files with 21 additions and 142 deletions
2
books
2
books
|
@ -1 +1 @@
|
||||||
Subproject commit 950c742b3d66cc7ac53bd0663a41315f001da1c4
|
Subproject commit e9790315c2510315e270a7a4c4921825e9918039
|
14
dist/epub.js
vendored
14
dist/epub.js
vendored
|
@ -4480,7 +4480,7 @@ EPUBJS.View.prototype.addStylesheetRules = function(rules) {
|
||||||
|
|
||||||
if(!this.document) return;
|
if(!this.document) return;
|
||||||
|
|
||||||
var styleEl = this.document.createElement('style');
|
styleEl = this.document.createElement('style');
|
||||||
|
|
||||||
// Append style element to head
|
// Append style element to head
|
||||||
this.document.head.appendChild(styleEl);
|
this.document.head.appendChild(styleEl);
|
||||||
|
@ -5322,7 +5322,7 @@ EPUBJS.Rendition.prototype.next = function(){
|
||||||
|
|
||||||
if(next) {
|
if(next) {
|
||||||
view = this.createView(next);
|
view = this.createView(next);
|
||||||
return this.append(view);
|
return this.fill(view);
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -5341,7 +5341,7 @@ EPUBJS.Rendition.prototype.prev = function(){
|
||||||
prev = this.views.first().section.prev();
|
prev = this.views.first().section.prev();
|
||||||
if(prev) {
|
if(prev) {
|
||||||
view = this.createView(prev);
|
view = this.createView(prev);
|
||||||
return this.append(view);
|
return this.fill(view);
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -5377,14 +5377,14 @@ EPUBJS.Rendition.prototype.isVisible = function(view, offsetPrev, offsetNext, _c
|
||||||
var container = _container || this.container.getBoundingClientRect();
|
var container = _container || this.container.getBoundingClientRect();
|
||||||
|
|
||||||
if(this.settings.axis === "horizontal" &&
|
if(this.settings.axis === "horizontal" &&
|
||||||
(position.right > container.left - offsetPrev) &&
|
position.right > container.left - offsetPrev &&
|
||||||
!(position.left >= container.right + offsetNext)) {
|
position.left < container.right + offsetNext) {
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
} else if(this.settings.axis === "vertical" &&
|
} else if(this.settings.axis === "vertical" &&
|
||||||
(position.bottom > container.top - offsetPrev) &&
|
position.bottom > container.top - offsetPrev &&
|
||||||
!(position.top >= container.bottom + offsetNext)) {
|
position.top < container.bottom + offsetNext) {
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
2
dist/epub.min.js
vendored
2
dist/epub.min.js
vendored
File diff suppressed because one or more lines are too long
|
@ -15,17 +15,9 @@
|
||||||
color: #333;
|
color: #333;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
/* position: absolute; */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.epub-container {
|
.epub-container {
|
||||||
/* display: block;
|
|
||||||
*/ /*width: 100%;*/
|
|
||||||
/*height: 100%;*/
|
|
||||||
/* text-align: center;
|
|
||||||
*/ /*position: absolute;
|
|
||||||
top: 0;
|
|
||||||
left: 0;*/
|
|
||||||
min-width: 320px;
|
min-width: 320px;
|
||||||
margin: 0 auto;
|
margin: 0 auto;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,103 +0,0 @@
|
||||||
<!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>
|
|
|
@ -4,18 +4,8 @@
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<title>EPUB.js Basic Example</title>
|
<title>EPUB.js Basic Example</title>
|
||||||
|
|
||||||
<script src="../bower_components/rsvp/rsvp.js"></script>
|
<script src="../dist/epub.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>
|
|
||||||
|
|
||||||
<style type="text/css">
|
<style type="text/css">
|
||||||
body {
|
body {
|
||||||
|
@ -23,7 +13,7 @@
|
||||||
height: 100%;
|
height: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
#viewer {
|
#viewer {
|
||||||
display: block;
|
display: block;
|
||||||
margin: 5% auto;
|
margin: 5% auto;
|
||||||
width: 80%;
|
width: 80%;
|
||||||
|
@ -35,7 +25,7 @@
|
||||||
left: 40px;
|
left: 40px;
|
||||||
}
|
}
|
||||||
|
|
||||||
#next {
|
#next {
|
||||||
right: 40px;
|
right: 40px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,7 +46,7 @@
|
||||||
.arrow:hover {
|
.arrow:hover {
|
||||||
color: #777;
|
color: #777;
|
||||||
}
|
}
|
||||||
|
|
||||||
.arrow:active {
|
.arrow:active {
|
||||||
color: #000;
|
color: #000;
|
||||||
}
|
}
|
|
@ -119,7 +119,7 @@
|
||||||
<script>
|
<script>
|
||||||
// Load the opf
|
// Load the opf
|
||||||
// var book = ePub("https://s3.amazonaws.com/moby-dick/OPS/package.opf");
|
// var book = ePub("https://s3.amazonaws.com/moby-dick/OPS/package.opf");
|
||||||
var book = ePub("../books/alice/OPS/package.opf");
|
var book = ePub("books/alice/OPS/package.opf");
|
||||||
var rendition = book.renderTo("viewer", {
|
var rendition = book.renderTo("viewer", {
|
||||||
method: "paginate",
|
method: "paginate",
|
||||||
width: "100%",
|
width: "100%",
|
||||||
|
|
|
@ -425,7 +425,7 @@ EPUBJS.Rendition.prototype.next = function(){
|
||||||
|
|
||||||
if(next) {
|
if(next) {
|
||||||
view = this.createView(next);
|
view = this.createView(next);
|
||||||
return this.append(view);
|
return this.fill(view);
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -444,7 +444,7 @@ EPUBJS.Rendition.prototype.prev = function(){
|
||||||
prev = this.views.first().section.prev();
|
prev = this.views.first().section.prev();
|
||||||
if(prev) {
|
if(prev) {
|
||||||
view = this.createView(prev);
|
view = this.createView(prev);
|
||||||
return this.append(view);
|
return this.fill(view);
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -480,14 +480,14 @@ EPUBJS.Rendition.prototype.isVisible = function(view, offsetPrev, offsetNext, _c
|
||||||
var container = _container || this.container.getBoundingClientRect();
|
var container = _container || this.container.getBoundingClientRect();
|
||||||
|
|
||||||
if(this.settings.axis === "horizontal" &&
|
if(this.settings.axis === "horizontal" &&
|
||||||
(position.right > container.left - offsetPrev) &&
|
position.right > container.left - offsetPrev &&
|
||||||
!(position.left >= container.right + offsetNext)) {
|
position.left < container.right + offsetNext) {
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
} else if(this.settings.axis === "vertical" &&
|
} else if(this.settings.axis === "vertical" &&
|
||||||
(position.bottom > container.top - offsetPrev) &&
|
position.bottom > container.top - offsetPrev &&
|
||||||
!(position.top >= container.bottom + offsetNext)) {
|
position.top < container.bottom + offsetNext) {
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -641,7 +641,7 @@ EPUBJS.View.prototype.addStylesheetRules = function(rules) {
|
||||||
|
|
||||||
if(!this.document) return;
|
if(!this.document) return;
|
||||||
|
|
||||||
var styleEl = this.document.createElement('style');
|
styleEl = this.document.createElement('style');
|
||||||
|
|
||||||
// Append style element to head
|
// Append style element to head
|
||||||
this.document.head.appendChild(styleEl);
|
this.document.head.appendChild(styleEl);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue