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:
parent
b3a6f1f0c6
commit
6b25126f00
5 changed files with 268 additions and 8 deletions
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue