From cba065aab3979eb6c6b0fed70d62ccdb3a2b8e79 Mon Sep 17 00:00:00 2001 From: Kyle Boone Date: Wed, 26 Feb 2020 20:44:54 -0800 Subject: [PATCH] Updates to resizing handle --- js/src/mpl_widget.js | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/js/src/mpl_widget.js b/js/src/mpl_widget.js index 27ec907f..76110d13 100644 --- a/js/src/mpl_widget.js +++ b/js/src/mpl_widget.js @@ -90,13 +90,14 @@ var MPLCanvasModel = widgets.DOMWidgetModel.extend({ handle_resize: function(msg) { var size = msg['size']; - this.resize_canvas(size[0], size[1]); this.offscreen_context.drawImage(this.image, 0, 0); - this._for_each_view(function(view) { - view.resize_canvas(size[0], size[1]); - }); + if (!this.resize_requested) { + this._for_each_view(function(view) { + view.resize_canvas(size[0], size[1]); + }); + } this.send_message('refresh'); @@ -109,6 +110,11 @@ var MPLCanvasModel = widgets.DOMWidgetModel.extend({ }, resize: function(width, height) { + this._for_each_view(function(view) { + // Do an initial resize of each view, stretching the old canvas. + view.resize_canvas(width, height); + }); + if (this.resize_requested) { // If a resize was already requested, save the requested size for later this.requested_size = [width, height]; @@ -487,6 +493,11 @@ var MPLCanvasView = widgets.DOMWidgetView.extend({ } } + if (that.resizing) { + // Ignore other mouse events while resizing. + return; + } + if (name === 'motion_notify') { // If the mouse is on the handle, change the cursor style if (canvas_pos.x >= that.top_canvas.width - that.resize_handle_size &&