mirror of
https://github.com/futurepress/epub.js.git
synced 2025-10-04 15:09:16 +02:00
handle compressed epubs
This commit is contained in:
parent
0cfaa9cf2e
commit
cb813ab927
26 changed files with 5593 additions and 4871 deletions
|
@ -1,4 +1,4 @@
|
|||
/*! FuturePress - v0.1.0 - 2013-06-30 */
|
||||
/*! FuturePress - v0.1.0 - 2013-07-08 */
|
||||
|
||||
EPUBJS.Hooks.register("beforeChapterDisplay").endnotes = function(callback, chapter){
|
||||
|
||||
|
@ -156,44 +156,51 @@ EPUBJS.Hooks.register("beforeChapterDisplay").endnotes = function(callback, chap
|
|||
}
|
||||
|
||||
EPUBJS.Hooks.register("beforeChapterDisplay").smartimages = function(callback, chapter){
|
||||
|
||||
var image = chapter.doc.querySelectorAll('img'),
|
||||
items = Array.prototype.slice.call(image),
|
||||
iheight = chapter.doc.body.getBoundingClientRect().height,
|
||||
var images = chapter.doc.querySelectorAll('img'),
|
||||
items = Array.prototype.slice.call(images),
|
||||
iheight = chapter.height(),//chapter.doc.body.getBoundingClientRect().height,
|
||||
oheight;
|
||||
|
||||
items.forEach(function(item){
|
||||
|
||||
function size() {
|
||||
var itemRect = item.getBoundingClientRect(),
|
||||
height = itemRect.height,
|
||||
top = itemRect.top;
|
||||
|
||||
iheight = chapter.iframe.height;
|
||||
rectHeight = itemRect.height,
|
||||
top = itemRect.top,
|
||||
oHeight = item.getAttribute('data-height'),
|
||||
height = oHeight || rectHeight,
|
||||
newHeight;
|
||||
|
||||
iheight = chapter.height();
|
||||
if(top < 0) top = 0;
|
||||
|
||||
if(height + top >= iheight) {
|
||||
|
||||
if(top < iheight/2) {
|
||||
item.style.maxHeight = iheight - top + "px";
|
||||
newHeight = iheight - top;
|
||||
item.style.maxHeight = newHeight + "px";
|
||||
item.style.width= "auto";
|
||||
}else{
|
||||
|
||||
item.style.maxHeight = (height < iheight ? height : iheight) + "px";
|
||||
height = (height < iheight ? height : iheight);
|
||||
item.style.maxHeight = newHeight + "px";
|
||||
item.style.marginTop = iheight - top + "px";
|
||||
item.style.width= "auto";
|
||||
}
|
||||
|
||||
item.setAttribute('data-height', newHeight);
|
||||
|
||||
}else{
|
||||
item.style.removeProperty('max-height');
|
||||
item.style.removeProperty('margin-top');
|
||||
}
|
||||
}
|
||||
|
||||
item.addEventListener('load', size, false);
|
||||
|
||||
chapter.on("book:resized", size);
|
||||
|
||||
chapter.on("book:chapterDestroyed", function(){
|
||||
item.removeEventListener('load', size);
|
||||
chapter.off("book:resized", size);
|
||||
});
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue