Skip to content

Chart cursor does not stop at the left edge on mobile #301

Description

@aronsommer

Description

On mobile devices, when dragging the cursor in the elevation chart, the vertical line (.mouse-focus-line) does not stop at the left edge of the chart. It is possible to drag the line far to the left of the chart's visible area.

Steps to Reproduce

  1. Open a map with the elevation plugin on a mobile device.
  2. Tap and hold on the elevation chart to show the cursor.
  3. Drag your finger to the left, past the beginning of the chart.

Expected Behavior

The cursor should stop at the left edge of the chart.

Actual Behavior

The cursor continues to move to the left, off of the chart.

Suggested Fix

This can be fixed by clamping the xCoord value in src/components/chart.js.

In the _initBrush function, inside the focus constant, change the following line:

let xCoord  = coords[0];

to this:

let xCoord  = _.clamp(coords[0], [0, this._width()]); // Clamps the cursor position to the chart's bounds.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions