IE viewpoert scroll position fix

This commit is contained in:
Kovid Goyal 2012-01-06 13:46:31 +05:30
parent dfe9d4ff16
commit 61b8399e44
2 changed files with 17 additions and 3 deletions

View File

@ -68,8 +68,16 @@ get_current_time = (target) -> # {{{
viewport_to_document = (x, y, doc) -> # {{{ viewport_to_document = (x, y, doc) -> # {{{
win = doc.defaultView win = doc.defaultView
x += if win.scrollX then win.scrollX else 0 # These can be NaN on IE if typeof(win.pageXOffset) == 'number'
y += if win.scrollY then win.scrollY else 0 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 if doc != window.document
# We are in a frame # We are in a frame

View File

@ -2,6 +2,7 @@
<html> <html>
<head> <head>
<title>Testing CFI functionality</title> <title>Testing CFI functionality</title>
<link rel="shortcut icon" type="image/x-icon" href="http://calibre-ebook.com/favicon.ico" />
<script type="text/javascript" src="cfi.coffee"></script> <script type="text/javascript" src="cfi.coffee"></script>
<script type="text/javascript" src="cfi-test.coffee"></script> <script type="text/javascript" src="cfi-test.coffee"></script>
<style type="text/css"> <style type="text/css">
@ -73,7 +74,7 @@
<p>An invisible Comment: <!-- aaaaaa --> followed by some text</p> <p>An invisible Comment: <!-- aaaaaa --> followed by some text</p>
<p>An invalid (in HTML) CDATA: <![CDATA[CDATA]]> followed by some text</p> <p>An invalid (in HTML) CDATA: <![CDATA[CDATA]]> followed by some text</p>
<h2>Margins padding borders</h2> <h2>Margins padding borders</h2>
<p>Try clicking in the margins, borders and padding</p> <p>Try clicking in the margins, borders and padding. There should be no effect.</p>
<p id="whitespace">But I must explain to you how all this mistaken <p id="whitespace">But I must explain to you how all this mistaken
idea of denouncing pleasure and praising pain was born and I idea of denouncing pleasure and praising pain was born and I
@ -96,6 +97,11 @@
demoralized by the charms of pleasure of the moment, so blinded demoralized by the charms of pleasure of the moment, so blinded
by desire, that they cannot foresee</p> by desire, that they cannot foresee</p>
<h2>Lots of nested tags</h2>
<p>A <span>bunch of <span>nested<span> and</span> <span>sibling</span>
tags, all </span> mixed together</span>. <span>Click all</span>
over this paragraph to test<span> things.</span></p>
</div> </div>
<img id="marker" style="position: absolute; display:none; z-index:10" src="marker.png" alt="Marker" /> <img id="marker" style="position: absolute; display:none; z-index:10" src="marker.png" alt="Marker" />
</body> </body>