1
0
Fork 0
mirror of https://github.com/futurepress/epub.js.git synced 2025-10-03 14:59:18 +02:00

fixed endnotes bounding rects

This commit is contained in:
Fred Chasen 2013-04-01 10:46:08 -07:00
parent 2d81246827
commit b2c7b76b27
10 changed files with 85 additions and 41 deletions

View file

@ -1,7 +1,7 @@
FP.Hooks.register("beforeChapterDisplay").endnotes = function(callback, chapter){
var notes = chapter.doc.querySelectorAll('a[href]'),
items = Array.prototype.slice.call(notes),
items = Array.prototype.slice.call(notes), //[].slice.call()
attr = "epub:type",
type = "noteref",
popups = {};
@ -73,19 +73,20 @@ FP.Hooks.register("beforeChapterDisplay").endnotes = function(callback, chapter)
//-- get location of item
itemRect = item.getBoundingClientRect();
left = pos.left;
top = pos.top;
left = itemRect.left;
top = itemRect.top;
//-- show the popup
pop.classList.add("show");
//-- position the popup
pop.style.left = left - itemRect.width / 2 + "px";
pop.style.top = top + "px";
//-- checking to keep within current column
//-- locations of popup
popRect = pop.getBoundingClientRect();
//-- position the popup
pop.style.left = left - popRect.width / 2 + "px";
pop.style.top = top + "px";
//-- Adjust max height
if(maxHeight > iheight / 2.5) {
maxHeight = iheight / 2.5;
@ -93,7 +94,7 @@ FP.Hooks.register("beforeChapterDisplay").endnotes = function(callback, chapter)
}
//-- switch above / below
if(poppos.height + top >= iheight - 25) {
if(popRect.height + top >= iheight - 25) {
pop.style.top = top - popRect.height + "px";
pop.classList.add("above");
}else{