Skip to content

Commit

Permalink
Have added pinch zoom ux danvk#990, fix mobile device.
Browse files Browse the repository at this point in the history
  • Loading branch information
Richard Shine committed Apr 13, 2020
1 parent f0dd931 commit deaf6d8
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions src/dygraph-interaction-model.js
Original file line number Diff line number Diff line change
Expand Up @@ -418,12 +418,13 @@ DygraphInteraction.startTouch = function(event, g, context) {
var touches = [];
for (var i = 0; i < event.touches.length; i++) {
var t = event.touches[i];
var rect = t.target.getBoundingClientRect();
// we dispense with 'dragGetX_' because all touchBrowsers support pageX
touches.push({
pageX: t.pageX,
pageY: t.pageY,
dataX: g.toDataXCoord(t.pageX),
dataY: g.toDataYCoord(t.pageY)
dataX: g.toDataXCoord(t.clientX-rect.left),
dataY: g.toDataYCoord(t.clientY-rect.top)
// identifier: t.identifier
});
}
Expand Down Expand Up @@ -536,8 +537,8 @@ DygraphInteraction.moveTouch = function(event, g, context) {
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
c_init.dataX - swipe.dataX / xScale + (context.initialRange.x[0] - c_init.dataX) / xScale,
c_init.dataX - swipe.dataX / xScale + (context.initialRange.x[1] - c_init.dataX) / xScale
];
didZoom = true;
}
Expand All @@ -550,8 +551,8 @@ DygraphInteraction.moveTouch = function(event, g, context) {
// TODO(danvk): implement
} else {
axis.valueRange = [
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
c_init.dataY - swipe.dataY / yScale + (context.initialRange.y[0] - c_init.dataY) / yScale,
c_init.dataY - swipe.dataY / yScale + (context.initialRange.y[1] - c_init.dataY) / yScale
];
didZoom = true;
}
Expand Down Expand Up @@ -591,9 +592,6 @@ DygraphInteraction.endTouch = function(event, g, context) {
// no double-tap, pan or pinch so its a touchover
event.isTouchOver = true;
g.mouseMoveHandler_(event);
// g.mousemove(event);f



}

Expand Down

0 comments on commit deaf6d8

Please sign in to comment.