[Pkg-javascript-commits] [d3-tip.js] 92/277: fix tip position when document is scrolled in firefox

bhuvan krishna bhuvan-guest at moszumanska.debian.org
Thu Dec 8 06:57:20 UTC 2016


This is an automated email from the git hooks/post-receive script.

bhuvan-guest pushed a commit to branch master
in repository d3-tip.js.

commit aa6435a747f9c797524968bbe5ab8c62548547f3
Author: Justin Palmer <justin at github.com>
Date:   Mon Apr 8 13:30:14 2013 -0700

    fix tip position when document is scrolled in firefox
---
 examples/bars.html |  1 +
 src/d3.tip.js      | 29 ++++++++++++++++++-----------
 2 files changed, 19 insertions(+), 11 deletions(-)

diff --git a/examples/bars.html b/examples/bars.html
index f007b34..63932e0 100644
--- a/examples/bars.html
+++ b/examples/bars.html
@@ -11,6 +11,7 @@
     padding: 40px;
     font-family: "Helvetica Neue", Helvetica, sans-serif;
     font-size: 12px;
+    height: 1000px;
   }
 
   .d3-tip {
diff --git a/src/d3.tip.js b/src/d3.tip.js
index a62c774..2f3498a 100644
--- a/src/d3.tip.js
+++ b/src/d3.tip.js
@@ -177,17 +177,24 @@ d3.tip = function() {
   //
   // Returns an Object {n, s, e, w, nw, sw, ne, se}
   function get_screen_bbox() {
-    var target = d3.event.target,
-        bbox   = {},
-        matrix = target.getScreenCTM(),
-        tbbox  = target.getBBox(),
-        width  = tbbox.width,
-        height = tbbox.height,
-        x      = tbbox.x,
-        y      = tbbox.y
-
-    point.x = x + document.body.scrollLeft
-    point.y = y + document.body.scrollTop
+    var target     = d3.event.target,
+        bbox       = {},
+        matrix     = target.getScreenCTM(),
+        tbbox      = target.getBBox(),
+        width      = tbbox.width,
+        height     = tbbox.height,
+        x          = tbbox.x,
+        y          = tbbox.y,
+        scrollTop = document.body.scrollTop
+        scrollLeft = document.body.scrollLeft
+
+    if(document.documentElement && document.documentElement.scrollTop) {
+      scrollTop = document.documentElement.scrollTop
+      scrollLeft = document.documentElement.scrollLeft
+    }
+
+    point.x = x + scrollLeft
+    point.y = y + scrollTop
     bbox.nw = point.matrixTransform(matrix)
     point.x += width
     bbox.ne = point.matrixTransform(matrix)

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/d3-tip.js.git



More information about the Pkg-javascript-commits mailing list