mirror of
https://github.com/futurepress/epub.js.git
synced 2025-10-02 14:49:16 +02:00

* Initial embedding support * Updates for rendering in embedded webviews * toLowerCase nodeName check
80 lines
2.3 KiB
HTML
80 lines
2.3 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
|
|
<title></title>
|
|
|
|
<script src="../dist/epub.js"></script>
|
|
|
|
<style>
|
|
|
|
body {
|
|
margin: 0;
|
|
-webkit-scroll-snap-type: mandatory;
|
|
-webkit-scroll-snap-points-x: repeat(100%);
|
|
|
|
/*This scroll snap functionality is part of a polyfill
|
|
that enables the functionality in Chrome.*/
|
|
scroll-snap-type: mandatory;
|
|
scroll-snap-points-x: repeat(100%);
|
|
width: 100vw;
|
|
overflow: auto;
|
|
}
|
|
|
|
.epub-container {
|
|
margin: 0;
|
|
/*-webkit-scroll-snap-type: mandatory;
|
|
-webkit-scroll-snap-points-x: repeat(100%);*/
|
|
/* -webkit-overflow-scrolling: touch; */
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
|
|
<script>
|
|
var params = URLSearchParams && new URLSearchParams(document.location.search.substring(1));
|
|
var url = params && params.get("url") && decodeURIComponent(params.get("url"));
|
|
var currentCfi = (params && params.get("cfi")) ? params.get("cfi") : undefined;
|
|
var currentSectionIndex = (params && params.get("loc")) ? parseInt(params.get("loc")) : 6;
|
|
|
|
// Load the opf
|
|
var book = ePub(url || "https://s3.amazonaws.com/moby-dick/");
|
|
var rendition = book.renderTo(document.body, {
|
|
// width: "100vw",
|
|
// height: "100vh",
|
|
overflow: "visible",
|
|
manager: "continuous",
|
|
flow: "paginated"
|
|
});
|
|
|
|
rendition.display(currentCfi || currentSectionIndex);
|
|
|
|
|
|
rendition.on("rendered", function(section){
|
|
var nextSection = section.next();
|
|
var prevSection = section.prev();
|
|
|
|
var current = book.navigation && book.navigation.get(section.href);
|
|
|
|
if (current) {
|
|
document.title = current.label;
|
|
}
|
|
});
|
|
|
|
rendition.on("relocated", function(location){
|
|
console.log("locationChanged", location)
|
|
console.log("locationChanged start", location.start.cfi)
|
|
console.log("locationChanged end", location.end.cfi)
|
|
});
|
|
|
|
window.addEventListener("unload", function () {
|
|
console.log("unloading");
|
|
this.book.destroy();
|
|
});
|
|
|
|
</script>
|
|
<!-- <script src="../node_modules/scrollsnap-polyfill/vendor/philipwalton/polyfill.js"></script>
|
|
<script src="../node_modules/scrollsnap-polyfill/src/scrollsnap-polyfill.js"></script> -->
|
|
</body>
|
|
</html>
|