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

added Endnotes pop up and image resizing

This commit is contained in:
Fred Chasen 2013-03-26 17:26:47 -07:00
parent d69e12dc7e
commit 7f41f00775
18 changed files with 335 additions and 25 deletions

42
fpjs/hooks/smartimages.js Normal file
View file

@ -0,0 +1,42 @@
FP.Hooks.register("beforeChapterDisplay").smartimages = function(callback, chapter){
var image = chapter.doc.querySelectorAll('img'),
items = Array.prototype.slice.call(image),
iheight = chapter.iframe.height,
oheight;
items.forEach(function(item){
function size() {
var height = item.offsetHeight,
top = item.offsetTop;
iheight = chapter.iframe.height;
if(height + top >= iheight) {
if(top < iheight/2) {
item.style.maxHeight = iheight - top + "px";
}else{
item.style.maxHeight = (height < iheight ? height : iheight) + "px";
item.style.marginTop = iheight - top + "px";
}
}else{
item.style.removeProperty('max-height');
item.style.removeProperty('margin-top');
}
}
chapter.book.listenUntil("book:resized", "book:chapterDestroy", size);
size();
});
if(callback) callback();
}