From: Dan Vanderkam Date: Thu, 20 Aug 2009 23:35:10 +0000 (+0000) Subject: Delay calculation of offsets when zooming. I believe this fixes issue 10. X-Git-Tag: v1.0.0~911 X-Git-Url: https://adrianiainlam.tk/git/?a=commitdiff_plain;h=67e650dcfdbb3b8c11a9025456839fa7154704d2;p=dygraphs.git Delay calculation of offsets when zooming. I believe this fixes issue 10. --- diff --git a/docs/dygraph-combined.js b/docs/dygraph-combined.js index 2ea5555..de440fa 100644 --- a/docs/dygraph-combined.js +++ b/docs/dygraph-combined.js @@ -4899,8 +4899,8 @@ var _75=null; var _76=null; var _77=null; var _78=null; -var px=PlotKit.Base.findPosX(this.canvas_); -var py=PlotKit.Base.findPosY(this.canvas_); +var px=-1000; +var py=-1000; var _81=function(e){ return e.mouse().page.x-px; }; @@ -4917,6 +4917,8 @@ _78=_76; }); connect(this.hidden_,"onmousedown",function(_84){ _73=true; +px=PlotKit.Base.findPosX(_72.canvas_); +py=PlotKit.Base.findPosY(_72.canvas_); _74=_81(_84); _75=_82(_84); }); @@ -4957,7 +4959,9 @@ _72.dateWindow_=null; _72.drawGraph_(_72.rawData_); var _91=_72.rawData_[0][0]; var _92=_72.rawData_[_72.rawData_.length-1][0]; +if(_72.zoomCallback_){ _72.zoomCallback_(_91,_92); +} }); }; DateGraph.prototype.drawZoomRect_=function(_93,_94,_95){ @@ -4992,7 +4996,9 @@ _100=_98[_98.length-1].xval; } this.dateWindow_=[_99,_100]; this.drawGraph_(this.rawData_); +if(this.zoomCallback_){ this.zoomCallback_(_99,_100); +} }; DateGraph.prototype.mouseMove_=function(_102){ var _103=_102.mouse().page.x-PlotKit.Base.findPosX(this.hidden_); diff --git a/dygraph-combined.js b/dygraph-combined.js index 2ea5555..de440fa 100644 --- a/dygraph-combined.js +++ b/dygraph-combined.js @@ -4899,8 +4899,8 @@ var _75=null; var _76=null; var _77=null; var _78=null; -var px=PlotKit.Base.findPosX(this.canvas_); -var py=PlotKit.Base.findPosY(this.canvas_); +var px=-1000; +var py=-1000; var _81=function(e){ return e.mouse().page.x-px; }; @@ -4917,6 +4917,8 @@ _78=_76; }); connect(this.hidden_,"onmousedown",function(_84){ _73=true; +px=PlotKit.Base.findPosX(_72.canvas_); +py=PlotKit.Base.findPosY(_72.canvas_); _74=_81(_84); _75=_82(_84); }); @@ -4957,7 +4959,9 @@ _72.dateWindow_=null; _72.drawGraph_(_72.rawData_); var _91=_72.rawData_[0][0]; var _92=_72.rawData_[_72.rawData_.length-1][0]; +if(_72.zoomCallback_){ _72.zoomCallback_(_91,_92); +} }); }; DateGraph.prototype.drawZoomRect_=function(_93,_94,_95){ @@ -4992,7 +4996,9 @@ _100=_98[_98.length-1].xval; } this.dateWindow_=[_99,_100]; this.drawGraph_(this.rawData_); +if(this.zoomCallback_){ this.zoomCallback_(_99,_100); +} }; DateGraph.prototype.mouseMove_=function(_102){ var _103=_102.mouse().page.x-PlotKit.Base.findPosX(this.hidden_); diff --git a/dygraph.js b/dygraph.js index 4f08596..971dd44 100644 --- a/dygraph.js +++ b/dygraph.js @@ -290,8 +290,8 @@ DateGraph.prototype.createDragInterface_ = function() { var prevEndX = null; // Utility function to convert page-wide coordinates to canvas coords - var px = PlotKit.Base.findPosX(this.canvas_); - var py = PlotKit.Base.findPosY(this.canvas_); + var px = 0; + var py = 0; var getX = function(e) { return e.mouse().page.x - px }; var getY = function(e) { return e.mouse().page.y - py }; @@ -309,6 +309,8 @@ DateGraph.prototype.createDragInterface_ = function() { // Track the beginning of drag events connect(this.hidden_, 'onmousedown', function(event) { mouseDown = true; + px = PlotKit.Base.findPosX(self.canvas_); + py = PlotKit.Base.findPosY(self.canvas_); dragStartX = getX(event); dragStartY = getY(event); }); @@ -367,7 +369,9 @@ DateGraph.prototype.createDragInterface_ = function() { self.drawGraph_(self.rawData_); var minDate = self.rawData_[0][0]; var maxDate = self.rawData_[self.rawData_.length - 1][0]; - self.zoomCallback_(minDate, maxDate); + if (self.zoomCallback_) { + self.zoomCallback_(minDate, maxDate); + } }); }; @@ -426,7 +430,9 @@ DateGraph.prototype.doZoom_ = function(lowX, highX) { this.dateWindow_ = [minDate, maxDate]; this.drawGraph_(this.rawData_); - this.zoomCallback_(minDate, maxDate); + if (this.zoomCallback_) { + this.zoomCallback_(minDate, maxDate); + } }; /**