Broken zoom on touch devices [fix provided] #803

Open
iamgreaser opened this Issue Dec 5, 2016 · 0 comments

Projects

None yet

1 participant

@iamgreaser

File is dygraph-interaction-model.js, line 457 at the time of writing is the offending line.

    // Make pinches in a 45-degree swath around either axis 1-dimensional zooms.
    var initialAngle = 180 / Math.PI * Math.atan2(
        context.initialPinchCenter.pageY - touches[0].pageY,
        touches[0].pageX - context.initialPinchCenter.pageX);

    // use symmetry to get it into the first quadrant.
    initialAngle = Math.abs(initialAngle);
    if (initialAngle > 90) initialAngle = 90 - initialAngle;

    context.touchDirections = {
      x: (initialAngle < (90 - 45/2)),
      y: (initialAngle > 45/2)
    };

The offending line:

    if (initialAngle > 90) initialAngle = 90 - initialAngle;

This should be:

    if (initialAngle > 90) initialAngle = 180 - initialAngle;

Otherwise an initialAngle of 135 ends up being calculated as -45.

This has been tested and it works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment