From 5e60386d4e050cefa5dada1d55718225fbd4c32f Mon Sep 17 00:00:00 2001 From: Dan Vanderkam Date: Thu, 4 Feb 2010 21:51:55 -0800 Subject: [PATCH] change for Safari suggested by bearlanding --- dygraph.js | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/dygraph.js b/dygraph.js index d9c0e27..9611ba9 100644 --- a/dygraph.js +++ b/dygraph.js @@ -431,34 +431,40 @@ Dygraph.prototype.setColors_ = function() { Dygraph.update(this.layoutOptions_, this.attrs_); } -// The following functions are from quirksmode.org +// The following functions are from quirksmode.org with a modification for Safari from +// http://blog.firetree.net/2005/07/04/javascript-find-position/ // http://www.quirksmode.org/js/findpos.html Dygraph.findPosX = function(obj) { var curleft = 0; - if (obj.offsetParent) { - while (obj.offsetParent) { + if(obj.offsetParent) + while(1) + { curleft += obj.offsetLeft; + if(!obj.offsetParent) + break; obj = obj.offsetParent; } - } - else if (obj.x) + else if(obj.x) curleft += obj.x; return curleft; }; Dygraph.findPosY = function(obj) { var curtop = 0; - if (obj.offsetParent) { - while (obj.offsetParent) { + if(obj.offsetParent) + while(1) + { curtop += obj.offsetTop; + if(!obj.offsetParent) + break; obj = obj.offsetParent; } - } - else if (obj.y) + else if(obj.y) curtop += obj.y; return curtop; }; + /** * Create the div that contains information on the selected point(s) * This goes in the top right of the canvas, unless an external div has already -- 2.7.4