1
0
Fork 0
mirror of https://github.com/futurepress/epub.js.git synced 2025-10-04 15:09:16 +02:00

BUGFIX getFirstVisible did take embedded elements into account

This commit is contained in:
Ben De Meester 2015-01-07 11:14:31 +01:00
parent da11659d6c
commit 6555a61bff

View file

@ -484,6 +484,16 @@ EPUBJS.Renderer.prototype.firstElementisTextNode = function(node) {
return false;
};
EPUBJS.Renderer.prototype.isGoodNode = function(node) {
"use strict";
var embeddedElements = ["audio", "canvas", "embed", "iframe", "img", "math", "object", "svg", "video"];
if (embeddedElements.indexOf(node.tagName.toLowerCase()) !== -1) {
// Embedded elements usually do not have a text node as first element, but are also good nodes
return true;
}
return this.firstElementisTextNode(node);
};
// Walk the node tree from a start element to next visible element
EPUBJS.Renderer.prototype.walk = function(node, x, y) {
var r, children, leng,
@ -495,7 +505,7 @@ EPUBJS.Renderer.prototype.walk = function(node, x, y) {
while(!r && stack.length) {
node = stack.shift();
if( this.containsPoint(node, x, y) && this.firstElementisTextNode(node)) {
if( this.containsPoint(node, x, y) && this.isGoodNode(node)) {
r = node;
}