Skip to content

cursor.drag: Continue updating/clamping zoom box when mouse leaves chart area #1126

@GazozBaba

Description

@GazozBaba

Hi there,

I'm using uPlot with cursor.drag enabled for both axes:

uPlot.options.cursor.drag = { x: true, y: true }

While it works as expected within the chart area, I noticed that the drag/zoom box stops updating as soon as the mouse cursor leaves the u-over / chart area.

The Goal:
I would like the zoom box to continue updating based on the mouse position, even when the cursor is outside the chart, by clamping the coordinates to the chart boundaries.

Expected Behavior:

  1. Horizontal Exit: If I drag to the left/right edge and then move the cursor vertically outside the chart, the zoom box should stay clamped to the horizontal boundary but continue to expand/contract vertically.
  2. Vertical Exit: If I drag to the top/bottom edge and then move horizontally outside, the zoom box should stay clamped vertically but continue extending horizontally.

Current Behavior:
The mousemove listener (or the internal logic) seems to stop updating the selection box once the cursor is no longer over the chart element.

Question:
Is there a native configuration or a specific hook to enable this "clamping" behavior? Or does this require a custom implementation to override the default drag logic?

uPlot Version: 1.6.32

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