mpl-extensions / mpl-pan-zoom

Zooming and Panning for Matplotlib plots
https://mpl-pan-zoom.rtfd.io
BSD 3-Clause "New" or "Revised" License
1 stars 0 forks source link

zoom_factory does not prevent scroll events in WebAgg backend #8

Open antoniovazquezblanco opened 1 year ago

antoniovazquezblanco commented 1 year ago

Bug report

I am using zoom_factory with the WebAgg backend. Using the scroll wheel on the canvas does not prevent my browser from scrolling...

zoom_factory

Code for reproduction

#!/usr/bin/env python

import matplotlib
from matplotlib import pyplot
from mpl_interactions import zoom_factory
import numpy as np

matplotlib.use("WebAgg")

fig = pyplot.gcf()
zoom_factory(fig.gca())

t = np.arange(0.0, 2.0, 0.01)
s = 1 + np.sin(2 * np.pi * t)
fig.gca().plot(t, s)

pyplot.show()

Actual outcome

Scroll affects both my figure and the browser window...

Expected outcome

Scroll only affects my figure...

Version Info

ianhi commented 1 year ago

This is unfortunately a bug (or rather missing feature) in the webagg backend. I fixed this in ipympl (based on webagg) like this:

https://github.com/matplotlib/ipympl/blob/9b85cab605c960365e4f217589f8aa7ac6c31274/src/mpl_widget.ts#L547-L551

so I suspect that something similar could be implemented added to webagg here: https://github.com/matplotlib/matplotlib/blob/515cce40f14a4fe4eed15ddaa569052badb71229/lib/matplotlib/backends/web_backend/js/mpl.js#L301-L308

I suggest you open a feature request on the matplotlib repo for this. (feel free to tag me as well) (edit see https://github.com/matplotlib/matplotlib/issues/26032)