1
0
Fork 0
mirror of https://github.com/futurepress/epub.js.git synced 2025-10-05 15:32:55 +02:00

Updated timing, check for script prop, add viewport metatags

This commit is contained in:
Fred Chasen 2015-05-19 22:40:41 -04:00
parent 1f7a4a2ccf
commit b3a6f1f0c6
9 changed files with 62 additions and 82 deletions

64
dist/epub.js vendored
View file

@ -3062,12 +3062,12 @@ EPUBJS.Parser.prototype.manifest = function(manifestXml){
href = item.getAttribute('href') || '', href = item.getAttribute('href') || '',
type = item.getAttribute('media-type') || '', type = item.getAttribute('media-type') || '',
properties = item.getAttribute('properties') || ''; properties = item.getAttribute('properties') || '';
manifest[id] = { manifest[id] = {
'href' : href, 'href' : href,
// 'url' : href, // 'url' : href,
'type' : type, 'type' : type,
'properties' : properties 'properties' : properties.length ? properties.split(' ') : []
}; };
}); });
@ -3962,6 +3962,11 @@ EPUBJS.Spine.prototype.load = function(_package) {
if(manifestItem) { if(manifestItem) {
item.href = manifestItem.href; item.href = manifestItem.href;
item.url = this.baseUrl + item.href; item.url = this.baseUrl + item.href;
if(manifestItem.properties.length){
item.properties.push.apply(item.properties, manifestItem.properties)
}
} }
// if(index > 0) { // if(index > 0) {
@ -4306,27 +4311,9 @@ EPUBJS.View = function(section, horz) {
this.shown = false; this.shown = false;
this.rendered = false; this.rendered = false;
this.observe = false;
this.width = 0; this.width = 0;
this.height = 0; this.height = 0;
// this.paddingTopBottom = 0;
// this.paddingLeftRight = 0;
// this.marginTopBottom = 0;
// this.marginLeftRight = 0;
// this.borderTopBottom = 0;
// this.borderLeftRight = 0;
// this.elpaddingTopBottom = 0;
// this.elpaddingLeftRight = 0;
// this.elmarginTopBottom = 0;
// this.elmarginLeftRight = 0;
// this.elborderTopBottom = 0;
// this.elborderLeftRight = 0;
}; };
@ -4506,9 +4493,10 @@ EPUBJS.View.prototype.afterLoad = function() {
}.bind(this); }.bind(this);
} }
if(this.observe) { if(this.section.properties.indexOf("scripted") > -1){
this.observer = this.observe(this.document.body); this.observer = this.observe(this.document.body);
} }
}; };
@ -4576,8 +4564,8 @@ EPUBJS.View.prototype.observe = function(target) {
var observer = new MutationObserver(function(mutations) { var observer = new MutationObserver(function(mutations) {
renderer.expand(); renderer.expand();
// mutations.forEach(function(mutation) { // mutations.forEach(function(mutation) {
// console.log(mutation) // console.log(mutation);
// }); // });
}); });
// configuration of the observer: // configuration of the observer:
@ -4641,7 +4629,9 @@ EPUBJS.View.prototype.bounds = function() {
EPUBJS.View.prototype.destroy = function() { EPUBJS.View.prototype.destroy = function() {
// Stop observing // Stop observing
// this.observer.disconnect(); if(this.observer) {
this.observer.disconnect();
}
if(this.iframe){ if(this.iframe){
this.stopExpanding = true; this.stopExpanding = true;
@ -5246,7 +5236,8 @@ EPUBJS.Continuous = function(book, options) {
height: false, height: false,
overflow: "auto", overflow: "auto",
axis: "vertical", axis: "vertical",
offset: 500 offset: 500,
offsetDelta: 100
}); });
EPUBJS.core.extend(this.settings, options); EPUBJS.core.extend(this.settings, options);
@ -5680,16 +5671,16 @@ EPUBJS.Continuous.prototype.onScroll = function(){
if(!this.ignore) { if(!this.ignore) {
this.trigger("scroll", { // this.trigger("scroll", {
top: scrollTop, // top: scrollTop,
left: scrollLeft // left: scrollLeft
}); // });
if((this.scrollDeltaVert === 0 &&
this.scrollDeltaHorz === 0) ||
this.scrollDeltaVert > this.settings.offsetDelta ||
this.scrollDeltaHorz > this.settings.offsetDelta) {
if(this.scrollDeltaVert === 0 ||
this.scrollDeltaHorz === 0 ||
this.scrollDeltaVert > this.settings.offset / 2 ||
this.scrollDeltaHorz > this.settings.offset / 2) {
this.q.enqueue(this.check); this.q.enqueue(this.check);
this.scrollDeltaVert = 0; this.scrollDeltaVert = 0;
@ -5729,7 +5720,6 @@ EPUBJS.Continuous.prototype.scrollBy = function(x, y, silent){
this.container.scrollTop += y; this.container.scrollTop += y;
this.scrolled = true; this.scrolled = true;
//this.check();
}; };
EPUBJS.Continuous.prototype.scrollTo = function(x, y, silent){ EPUBJS.Continuous.prototype.scrollTo = function(x, y, silent){
@ -5747,9 +5737,7 @@ EPUBJS.Continuous.prototype.scrollTo = function(x, y, silent){
// }.bind(this), 10); // }.bind(this), 10);
// return; // return;
// }; // };
};
//this.check();
};
EPUBJS.Paginate = function(book, options) { EPUBJS.Paginate = function(book, options) {

4
dist/epub.min.js vendored

File diff suppressed because one or more lines are too long

View file

@ -2,7 +2,8 @@
<html> <html>
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<title>EPUB.js Basic Example</title> <meta name="viewport" content="width=device-width, initial-scale=1">
<title>EPUB.js Continuous Example</title>
<script src="../dist/epub.js"></script> <script src="../dist/epub.js"></script>
@ -92,7 +93,7 @@
// Load the opf // Load the opf
var book = ePub("../books/moby-dick/OPS/package.opf"); var book = ePub("../books/moby-dick/OPS/package.opf");
var rendition = book.renderTo("viewer", { method: "continuous", width: "60%", height: "100%" }); var rendition = book.renderTo("viewer", { method: "continuous", width: "60%", height: "100%" });
var displayed = rendition.display(currentSectionIndex); var displayed = rendition.display();
displayed.then(function(renderer){ displayed.then(function(renderer){

View file

@ -2,7 +2,9 @@
<html> <html>
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<title>EPUB.js Basic Example</title> <meta name="viewport" content="width=device-width, initial-scale=1">
<title>EPUB.js Pagination Example</title>
<script src="../dist/epub.js"></script> <script src="../dist/epub.js"></script>

View file

@ -2,7 +2,8 @@
<html> <html>
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<title>EPUB.js Basic Example</title> <meta name="viewport" content="width=device-width, initial-scale=1">
<title>EPUB.js Single Example</title>
<script src="../dist/epub.js"></script> <script src="../dist/epub.js"></script>

View file

@ -9,7 +9,8 @@ EPUBJS.Continuous = function(book, options) {
height: false, height: false,
overflow: "auto", overflow: "auto",
axis: "vertical", axis: "vertical",
offset: 500 offset: 500,
offsetDelta: 100
}); });
EPUBJS.core.extend(this.settings, options); EPUBJS.core.extend(this.settings, options);
@ -443,16 +444,16 @@ EPUBJS.Continuous.prototype.onScroll = function(){
if(!this.ignore) { if(!this.ignore) {
this.trigger("scroll", { // this.trigger("scroll", {
top: scrollTop, // top: scrollTop,
left: scrollLeft // left: scrollLeft
}); // });
if((this.scrollDeltaVert === 0 &&
this.scrollDeltaHorz === 0) ||
this.scrollDeltaVert > this.settings.offsetDelta ||
this.scrollDeltaHorz > this.settings.offsetDelta) {
if(this.scrollDeltaVert === 0 ||
this.scrollDeltaHorz === 0 ||
this.scrollDeltaVert > this.settings.offset / 2 ||
this.scrollDeltaHorz > this.settings.offset / 2) {
this.q.enqueue(this.check); this.q.enqueue(this.check);
this.scrollDeltaVert = 0; this.scrollDeltaVert = 0;
@ -492,7 +493,6 @@ EPUBJS.Continuous.prototype.scrollBy = function(x, y, silent){
this.container.scrollTop += y; this.container.scrollTop += y;
this.scrolled = true; this.scrolled = true;
//this.check();
}; };
EPUBJS.Continuous.prototype.scrollTo = function(x, y, silent){ EPUBJS.Continuous.prototype.scrollTo = function(x, y, silent){
@ -510,6 +510,4 @@ EPUBJS.Continuous.prototype.scrollTo = function(x, y, silent){
// }.bind(this), 10); // }.bind(this), 10);
// return; // return;
// }; // };
};
//this.check();
};

View file

@ -180,12 +180,12 @@ EPUBJS.Parser.prototype.manifest = function(manifestXml){
href = item.getAttribute('href') || '', href = item.getAttribute('href') || '',
type = item.getAttribute('media-type') || '', type = item.getAttribute('media-type') || '',
properties = item.getAttribute('properties') || ''; properties = item.getAttribute('properties') || '';
manifest[id] = { manifest[id] = {
'href' : href, 'href' : href,
// 'url' : href, // 'url' : href,
'type' : type, 'type' : type,
'properties' : properties 'properties' : properties.length ? properties.split(' ') : []
}; };
}); });

View file

@ -24,6 +24,11 @@ EPUBJS.Spine.prototype.load = function(_package) {
if(manifestItem) { if(manifestItem) {
item.href = manifestItem.href; item.href = manifestItem.href;
item.url = this.baseUrl + item.href; item.url = this.baseUrl + item.href;
if(manifestItem.properties.length){
item.properties.push.apply(item.properties, manifestItem.properties)
}
} }
// if(index > 0) { // if(index > 0) {

View file

@ -16,27 +16,9 @@ EPUBJS.View = function(section, horz) {
this.shown = false; this.shown = false;
this.rendered = false; this.rendered = false;
this.observe = false;
this.width = 0; this.width = 0;
this.height = 0; this.height = 0;
// this.paddingTopBottom = 0;
// this.paddingLeftRight = 0;
// this.marginTopBottom = 0;
// this.marginLeftRight = 0;
// this.borderTopBottom = 0;
// this.borderLeftRight = 0;
// this.elpaddingTopBottom = 0;
// this.elpaddingLeftRight = 0;
// this.elmarginTopBottom = 0;
// this.elmarginLeftRight = 0;
// this.elborderTopBottom = 0;
// this.elborderLeftRight = 0;
}; };
@ -216,9 +198,10 @@ EPUBJS.View.prototype.afterLoad = function() {
}.bind(this); }.bind(this);
} }
if(this.observe) { if(this.section.properties.indexOf("scripted") > -1){
this.observer = this.observe(this.document.body); this.observer = this.observe(this.document.body);
} }
}; };
@ -286,8 +269,8 @@ EPUBJS.View.prototype.observe = function(target) {
var observer = new MutationObserver(function(mutations) { var observer = new MutationObserver(function(mutations) {
renderer.expand(); renderer.expand();
// mutations.forEach(function(mutation) { // mutations.forEach(function(mutation) {
// console.log(mutation) // console.log(mutation);
// }); // });
}); });
// configuration of the observer: // configuration of the observer:
@ -351,7 +334,9 @@ EPUBJS.View.prototype.bounds = function() {
EPUBJS.View.prototype.destroy = function() { EPUBJS.View.prototype.destroy = function() {
// Stop observing // Stop observing
// this.observer.disconnect(); if(this.observer) {
this.observer.disconnect();
}
if(this.iframe){ if(this.iframe){
this.stopExpanding = true; this.stopExpanding = true;