Skip to content

2181 block zooming with mousewheel in js root - #2418

Draft
cnuart wants to merge 5 commits into
masterfrom
2181-block-zooming-with-mousewheel-in-js-root
Draft

cnuart wants to merge 5 commits into
masterfrom
2181-block-zooming-with-mousewheel-in-js-root

Conversation

@cnuart

@cnuart cnuart commented Sep 11, 2026

Copy link
Copy Markdown

No description provided.

@cnuart cnuart linked an issue Sep 11, 2026 that may be closed by this pull request
@grzanka

grzanka commented Sep 13, 2026

Copy link
Copy Markdown
Contributor

This PR introduces another user unfriendly behaviour: once user zooms in intro the plot area there is no easy way to zoom out to the original plot size (see my comment: #2181 (comment)) . With zoom unlocked that could be done easily by scrolling out.

Take a look how I vibecoded it in a different app:
image

there is clear "Reset zoom" button added and JSROOT menu is completely hidden.

You can vibe-dig it out from the source code here: https://github.com/APTG/dedx_web

I propose to add such "reset zoom" behaviour here as well in some aestethic way, per-plot.

@grzanka grzanka left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see comments inline, you introduce a problem here

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

The reset behavior relies on undocumented JSROOT painter internals (scale_xmin/scale_ymax, zoom/unzoom) and changes interactive plotting behavior that warrants human/browser verification.

Pull request overview

This PR addresses issue #2181 by preventing accidental zooming of JSROOT plots when users scroll the results panel with the mouse wheel. It disables JSROOT's wheel-zoom globally and, since wheel zoom is a common way users reset the view, adds an explicit "Reset Zoom" control to each plot so the original view can be restored on demand.

Changes:

  • Set settings.ZoomWheel = false in useJsRootCanvas to block mouse-wheel zooming.
  • Capture the initial axis range after redraw (now consumed as a Promise) and expose a new resetZoom callback that restores it via the frame painter's zoom/unzoom.
  • Add a MUI Chip "Reset Zoom" button above the canvas in the 1D, 2D, and Multi-1D graph components.
File summaries
File Description
src/JsRoot/hook/useJsRootCanvas.tsx Disables wheel zoom, captures initial axis range from the painter, and exposes a resetZoom callback.
src/JsRoot/components/JsRootGraph1D.tsx Wraps the canvas and adds a "Reset Zoom" chip wired to resetZoom.
src/JsRoot/components/JsRootGraph2D.tsx Same "Reset Zoom" chip addition for the 2D graph.
src/JsRoot/components/JsRootMultiGraph1D.tsx Same "Reset Zoom" chip addition for the multi-graph 1D view.
Review details
  • Files reviewed: 4/4 changed files
  • Comments generated: 2
  • Review effort level: Balanced

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +55 to +63
<div>
<Box sx={{ display: 'flex', justifyContent: 'flex-start', mb: 1 }}>
<Chip
color='primary'
sx={{ fontSize: 12, margin: 0.5 }}
label='Reset Zoom'
onClick={resetZoom}
/>
</Box>

const fp = painter?.getFramePainter?.();

if (fp && !initialRangeRef.current) {

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Block zooming with mouse/wheel in JS Root

3 participants