Skip to content

Commit 1c3ce65

Browse files
committed
nb/webagg: Ignore pointer events on rubberband canvas
For some reason, even though the canvas and rubberband canvas are both in the same div, the latter causes WebKit to ignore resizing on the div. Making the rubberband canvas invisible to the pointer seems to fix it.
1 parent 76a5711 commit 1c3ce65

File tree

1 file changed

+9
-9
lines changed
  • lib/matplotlib/backends/web_backend/js

1 file changed

+9
-9
lines changed

lib/matplotlib/backends/web_backend/js/mpl.js

+9-9
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ mpl.figure.prototype._init_canvas = function () {
165165
));
166166
rubberband_canvas.setAttribute(
167167
'style',
168-
'box-sizing: content-box; position: absolute; left: 0; top: 0; z-index: 1;'
168+
'box-sizing: content-box; position: absolute; left: 0; top: 0; z-index: 1; pointer-events: none;'
169169
);
170170

171171
// Apply a ponyfill if ResizeObserver is not implemented by browser.
@@ -239,29 +239,29 @@ mpl.figure.prototype._init_canvas = function () {
239239
};
240240
}
241241

242-
rubberband_canvas.addEventListener(
242+
canvas.addEventListener(
243243
'mousedown',
244244
on_mouse_event_closure('button_press')
245245
);
246-
rubberband_canvas.addEventListener(
246+
canvas.addEventListener(
247247
'mouseup',
248248
on_mouse_event_closure('button_release')
249249
);
250-
rubberband_canvas.addEventListener(
250+
canvas.addEventListener(
251251
'dblclick',
252252
on_mouse_event_closure('dblclick')
253253
);
254254
// Throttle sequential mouse events to 1 every 20ms.
255-
rubberband_canvas.addEventListener(
255+
canvas.addEventListener(
256256
'mousemove',
257257
on_mouse_event_closure('motion_notify')
258258
);
259259

260-
rubberband_canvas.addEventListener(
260+
canvas.addEventListener(
261261
'mouseenter',
262262
on_mouse_event_closure('figure_enter')
263263
);
264-
rubberband_canvas.addEventListener(
264+
canvas.addEventListener(
265265
'mouseleave',
266266
on_mouse_event_closure('figure_leave')
267267
);
@@ -289,7 +289,7 @@ mpl.figure.prototype._init_canvas = function () {
289289
};
290290

291291
// Disable right mouse context menu.
292-
this.rubberband_canvas.addEventListener('contextmenu', function (_e) {
292+
canvas.addEventListener('contextmenu', function (_e) {
293293
event.preventDefault();
294294
return false;
295295
});
@@ -444,7 +444,7 @@ mpl.figure.prototype.handle_figure_label = function (fig, msg) {
444444
};
445445

446446
mpl.figure.prototype.handle_cursor = function (fig, msg) {
447-
fig.rubberband_canvas.style.cursor = msg['cursor'];
447+
fig.canvas.style.cursor = msg['cursor'];
448448
};
449449

450450
mpl.figure.prototype.handle_message = function (fig, msg) {

0 commit comments

Comments
 (0)