JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
fix new positioning code for scrolled editor
authorJason Woofenden <jason@jasonwoof.com>
Sat, 5 Mar 2016 05:09:49 +0000 (00:09 -0500)
committerJason Woofenden <jason@jasonwoof.com>
Sat, 5 Mar 2016 05:09:49 +0000 (00:09 -0500)
editor.coffee

index 956ade0..8014188 100644 (file)
@@ -73,9 +73,13 @@ window.cursor_to_xyh = cursor_to_xyh = (n, i) ->
                        rect = rect[0]
        else
                return x: 0, y: 0, w: 0, h: 0 # TODO return null, fix callers
+       doc = n.el.ownerDocument.documentElement
+       win = n.el.ownerDocument.defaultView
+       y_fix = win.pageYOffset - doc.clientTop
+       x_fix = win.pageXOffset - doc.clientLeft
        ret = {
-               x: rect.left
-               y: rect.top
+               x: rect.left + x_fix
+               y: rect.top + y_fix
                w: rect.width ? (rect.right - rect.left)
                h: rect.height ? (rect.top - rect.bottom)
        }