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) -> # {{{
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

View File

@ -2,6 +2,7 @@
<html>
<head>
<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-test.coffee"></script>
<style type="text/css">
@ -73,7 +74,7 @@
<p>An invisible Comment: <!-- aaaaaa --> followed by some text</p>
<p>An invalid (in HTML) CDATA: <![CDATA[CDATA]]> followed by some text</p>
<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
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
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>
<img id="marker" style="position: absolute; display:none; z-index:10" src="marker.png" alt="Marker" />
</body>