From 61b8399e449fbfadd5845011d919ab4b2e84f1c7 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 6 Jan 2012 13:46:31 +0530 Subject: [PATCH] IE viewpoert scroll position fix --- src/calibre/ebooks/oeb/display/cfi.coffee | 12 ++++++++++-- src/calibre/ebooks/oeb/display/test-cfi/index.html | 8 +++++++- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/calibre/ebooks/oeb/display/cfi.coffee b/src/calibre/ebooks/oeb/display/cfi.coffee index b471b3cb1b..bffa0f1ae4 100644 --- a/src/calibre/ebooks/oeb/display/cfi.coffee +++ b/src/calibre/ebooks/oeb/display/cfi.coffee @@ -68,8 +68,16 @@ get_current_time = (target) -> # {{{ viewport_to_document = (x, y, doc) -> # {{{ win = doc.defaultView - x += if win.scrollX then win.scrollX else 0 # These can be NaN on IE - y += if win.scrollY then win.scrollY else 0 + if typeof(win.pageXOffset) == 'number' + x += win.pageXOffset + y += win.pageYOffset + else # IE < 9 + if document.body and ( document.body.scrollLeft or document.body.scrollTop ) + x += document.body.scrollLeft + y += document.body.scrollTop + else if document.documentElement and ( document.documentElement.scrollLeft or document.documentElement.scrollTop) + y += document.documentElement.scrollTop + x += document.documentElement.scrollLeft if doc != window.document # We are in a frame diff --git a/src/calibre/ebooks/oeb/display/test-cfi/index.html b/src/calibre/ebooks/oeb/display/test-cfi/index.html index 6198d78244..cde2715ea4 100644 --- a/src/calibre/ebooks/oeb/display/test-cfi/index.html +++ b/src/calibre/ebooks/oeb/display/test-cfi/index.html @@ -2,6 +2,7 @@ Testing CFI functionality +