From b38afae5054dd36c309d3da755effc2d8da99b20 Mon Sep 17 00:00:00 2001 From: Dan Vanderkam Date: Fri, 8 Feb 2013 17:58:21 -0500 Subject: [PATCH] Call zoomCallback from touch interactions (issue 395) --- dygraph-interaction-model.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/dygraph-interaction-model.js b/dygraph-interaction-model.js index 9654f28..9ad636a 100644 --- a/dygraph-interaction-model.js +++ b/dygraph-interaction-model.js @@ -471,11 +471,13 @@ Dygraph.Interaction.moveTouch = function(event, g, context) { xScale = Math.min(8, Math.max(0.125, xScale)); yScale = Math.min(8, Math.max(0.125, yScale)); + var didZoom = false; if (context.touchDirections.x) { g.dateWindow_ = [ c_init.dataX - swipe.dataX + (context.initialRange.x[0] - c_init.dataX) / xScale, c_init.dataX - swipe.dataX + (context.initialRange.x[1] - c_init.dataX) / xScale ]; + didZoom = true; } if (context.touchDirections.y) { @@ -489,11 +491,18 @@ Dygraph.Interaction.moveTouch = function(event, g, context) { c_init.dataY - swipe.dataY + (context.initialRange.y[0] - c_init.dataY) / yScale, c_init.dataY - swipe.dataY + (context.initialRange.y[1] - c_init.dataY) / yScale ]; + didZoom = true; } } } g.drawGraph_(false); + + // We only call zoomCallback on zooms, not pans, to mirror desktop behavior. + if (didZoom && touches.length > 1 && g.attr_('zoomCallback')) { + var viewWindow = g.xAxisRange(); + g.attr_("zoomCallback")(viewWindow[0], viewWindow[1], g.yAxisRanges()); + } }; /** -- 2.7.4