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

Added single-full example, update views to expand on image load

This commit is contained in:
Fred Chasen 2015-05-20 16:29:57 -04:00
parent b3a6f1f0c6
commit 6b25126f00
5 changed files with 268 additions and 8 deletions

View file

@ -94,9 +94,18 @@ EPUBJS.Book.prototype.open = function(_url){
then(function(paths){
var packageUri = EPUBJS.core.uri(paths.packagePath);
book.packageUrl = _url + paths.packagePath;
book.url = _url + packageUri.directory; // Set Url relative to the content
book.encoding = paths.encoding;
// Set Url relative to the content
if(packageUri.origin) {
book.url = packageUri.base;
} else if(window){
location = EPUBJS.core.uri(window.location.href);
book.url = EPUBJS.core.resolveUrl(location.base, _url + packageUri.directory);
} else {
book.url = packageUri.directory;
}
return book.request(book.packageUrl);
}).catch(function(error) {
// handle errors in either of the two requests

View file

@ -201,8 +201,8 @@ EPUBJS.View.prototype.afterLoad = function() {
if(this.section.properties.indexOf("scripted") > -1){
this.observer = this.observe(this.document.body);
}
this.imageLoadListeners();
};
EPUBJS.View.prototype.expand = function(_defer, _count, _func) {
@ -292,6 +292,19 @@ EPUBJS.View.prototype.observe = function(target) {
// element.insertBefore(this.iframe, element.firstChild);
// };
EPUBJS.View.prototype.imageLoadListeners = function(target) {
var images = this.document.body.querySelectorAll("img");
var img;
for (var i = 0; i < images.length; i++) {
img = images[i];
if (typeof img.naturalWidth !== "undefined" &&
img.naturalWidth === 0) {
img.onload = this.expand.bind(this);
}
}
};
EPUBJS.View.prototype.show = function() {
this.shown = true;