-
Notifications
You must be signed in to change notification settings - Fork 231
Remove all resizing logic on the front-end #174
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -55,6 +55,9 @@ var MPLCanvasView = widgets.DOMWidgetView.extend({ | |
|
||
that.update_toolbar_position(); | ||
|
||
that.update_header_visible(); | ||
that.update_toolbar_visible(); | ||
|
||
that.model_events(); | ||
|
||
that.send_initialization_message(); | ||
|
@@ -80,12 +83,10 @@ var MPLCanvasView = widgets.DOMWidgetView.extend({ | |
|
||
update_header_visible: function() { | ||
this.header.style.display = this.model.get('header_visible') ? '': 'none'; | ||
this.request_resize(); | ||
}, | ||
|
||
update_toolbar_visible: function() { | ||
this.toolbar_view.el.style.display = this.model.get('toolbar_visible') ? '' : 'none'; | ||
this.request_resize(); | ||
}, | ||
|
||
update_toolbar_position: function() { | ||
|
@@ -117,8 +118,6 @@ var MPLCanvasView = widgets.DOMWidgetView.extend({ | |
this.el.appendChild(this.toolbar_view.el); | ||
} | ||
} | ||
|
||
this.request_resize(); | ||
}, | ||
|
||
clear: function() { | ||
|
@@ -227,60 +226,6 @@ var MPLCanvasView = widgets.DOMWidgetView.extend({ | |
this.figure.appendChild(this.footer); | ||
}, | ||
|
||
_calculate_decorations_size: function() { | ||
// Calculate the size of the decorations on the figure. | ||
var decorations_width = 0; | ||
var decorations_height = 0; | ||
|
||
// Toolbar size | ||
var toolbar_position = this.model.get('toolbar_position'); | ||
if (toolbar_position == 'top' || toolbar_position == 'bottom') { | ||
decorations_height += utils.get_full_size(this.toolbar_view.el).height; | ||
} else { | ||
decorations_width += utils.get_full_size(this.toolbar_view.el).width; | ||
} | ||
|
||
// Label sizes | ||
decorations_height += utils.get_full_size(this.header).height; | ||
decorations_height += utils.get_full_size(this.footer).height; | ||
|
||
// Margins on the canvas | ||
var canvas_div_margins = utils.get_margin_size(this.canvas_div); | ||
decorations_width += canvas_div_margins.width; | ||
decorations_height += canvas_div_margins.height; | ||
|
||
// Margins on the figure div | ||
var figure_margins = utils.get_margin_size(this.figure); | ||
decorations_width += figure_margins.width; | ||
decorations_height += figure_margins.height; | ||
|
||
return { | ||
width: decorations_width, | ||
height: decorations_height | ||
}; | ||
}, | ||
|
||
request_resize: function() { | ||
// Ensure that the image already exists. We ignore the first calls to resize | ||
// because we want the widget to first adapt to the figure size set in | ||
// matplotlib. | ||
if (!this.image.src) { | ||
return; | ||
} | ||
|
||
// Using the given widget size, figure out how big the canvas should be. | ||
var decorations_size = this._calculate_decorations_size(); | ||
|
||
var new_canvas_width = this.el.clientWidth - decorations_size.width; | ||
var new_canvas_height = this.el.clientHeight - decorations_size.height; | ||
|
||
// Ensure that the canvas size is a positive number. | ||
new_canvas_width = new_canvas_width < 1 ? 1 : new_canvas_width; | ||
new_canvas_height = new_canvas_height < 1 ? 1 : new_canvas_height; | ||
|
||
this.send_message('resize', {'width': new_canvas_width, 'height': new_canvas_height}); | ||
}, | ||
|
||
_resize_canvas: function(width, height) { | ||
// Keep the size of the canvas, and rubber band canvas in sync. | ||
this.canvas.setAttribute('width', width * this.ratio); | ||
|
@@ -292,13 +237,6 @@ var MPLCanvasView = widgets.DOMWidgetView.extend({ | |
|
||
this.canvas_div.style.width = width + 'px'; | ||
this.canvas_div.style.height = height + 'px'; | ||
|
||
// Figure out the widget size. | ||
var decorations_size = this._calculate_decorations_size(); | ||
|
||
// Reset the widget size to adapt to this figure. | ||
this.el.style.width = width + decorations_size.width + 'px'; | ||
this.el.style.height = height + decorations_size.height + 'px'; | ||
}, | ||
|
||
send_message: function(type, message = {}) { | ||
|
@@ -431,17 +369,6 @@ var MPLCanvasView = widgets.DOMWidgetView.extend({ | |
} | ||
}, | ||
|
||
processPhosphorMessage: function(msg) { | ||
MPLCanvasView.__super__.processPhosphorMessage.apply(this, arguments); | ||
|
||
switch (msg.type) { | ||
case 'resize': | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We don't want this, this was causing a redraw every time the plot container was resized in JupyterLab, but this redraw was useless (because the plot size is controlled by matplotlib, not JupyterLab), and it was causing some flickering. |
||
this.request_resize(); | ||
break; | ||
} | ||
}, | ||
|
||
|
||
mouse_event: function(name) { | ||
var that = this; | ||
var last_update = 0; | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here, all those
request_resize
were useless and were causing flickering.