From 71df2031ba26c81ac50d2214b2f45072b9f92b39 Mon Sep 17 00:00:00 2001 From: danielweck Date: Tue, 20 Sep 2016 17:51:53 +0100 Subject: [PATCH 1/2] submodule --- readium-cfi-js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readium-cfi-js b/readium-cfi-js index 37ca4bc92..74c9eb365 160000 --- a/readium-cfi-js +++ b/readium-cfi-js @@ -1 +1 @@ -Subproject commit 37ca4bc9266c349cfca8f84e43e86ea81bcc5f57 +Subproject commit 74c9eb365460fd28a884a639a4a039d09a931f70 From 058dd02b9f904b5e903342f24109bc8549bd8cfb Mon Sep 17 00:00:00 2001 From: "r.hanson" Date: Mon, 21 Nov 2016 16:56:50 -0600 Subject: [PATCH 2/2] In some cases, the book may have an image which is surrounded by a svg tag like this: In this case, the containing svg must be used to find the client rectangles. Some epub books have a cover page which is structured like this; with no other content. Without this change, it appears to readium that there is no visible content on the page, because it can't find the first visible cfi. --- js/views/cfi_navigation_logic.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/js/views/cfi_navigation_logic.js b/js/views/cfi_navigation_logic.js index 43d9e75a7..5e17ec283 100644 --- a/js/views/cfi_navigation_logic.js +++ b/js/views/cfi_navigation_logic.js @@ -424,6 +424,17 @@ var CfiNavigationLogic = function(options) { clientRectList = range.getClientRects(); } else { clientRectList = $el[0].getClientRects(); + + // If the element is something like this: then the svg:image does not produce client rectangles; so we move to the + // enclosing svg tag and get those rectangles + try { + if (clientRectList.length === 0 && $el[0].ownerSVGElement) { + clientRectList = $($el[0].ownerSVGElement)[0].getClientRects(); + } + } + catch (e) { + // silently swallow up the error; apparently we can't get clientRectList s + } } // all the separate rectangles (for detecting position of the element