Skip to content

panDelta[] stores movement beyond range #493

@devenbj

Description

@devenbj

Chartjs v3.2.0 (and 3.2.1), chart-zoom-plugin 1.0.0b4 (and 1.0.0b5), Chrome 90
When panning beyond the max or min ranges on a linear scale, the panDelta[scale.id] added in PR #474 stores the continued mouse movement.

If I keep scrolling, the graph stops moving (expected), but to scroll in the opposite direction, I need to scroll until the delta is zero before the chart moves. Makes it seem like the pan function is not working.

In the example below, scroll to the right five times after it stops moving. Then scroll to the left.
What Happens: You need to scroll left five times before graph begins panning again
What is Expected: Immediately pans to the left... panning beyond the boundary should stop movement, not accumulate panning "debt"

https://codepen.io/pen/?template=NWpKzpq

The CodePen has the problem. Changing the linked chartjs-plugin-zoom.min.js to beta 3 will work. Specifically changing the core.js file from:
panDelta[scale.id] = delta;
to:
panDelta[scale.id] = 0;
reverted the behavior.

Suggested fixes:

  • ignore panDelta if pan is in opposite direction
  • set panDelta to zero when the drag goes beyond the max or min

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions