Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 19a6a84

Browse files
committed
nbagg: Ensure elements use content-box sizing.
This reverts the notebook's blanket change of all elements to border-box sizing.
1 parent 6c29c48 commit 19a6a84

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ mpl.figure = function (figure_id, websocket, ondownload, parent_element) {
4646
this.image_mode = 'full';
4747

4848
this.root = document.createElement('div');
49-
this._root_extra_style(this.root);
5049
this.root.setAttribute('style', 'display: inline-block');
50+
this._root_extra_style(this.root);
5151

5252
parent_element.appendChild(this.root);
5353

@@ -113,7 +113,9 @@ mpl.figure.prototype._init_canvas = function () {
113113
canvas_div.setAttribute(
114114
'style',
115115
'border: 1px solid #ddd;' +
116+
'box-sizing: content-box;' +
116117
'clear: both;' +
118+
'outline: 0;' +
117119
'overflow: hidden;' +
118120
'position: relative;' +
119121
'resize: both;'
@@ -139,7 +141,7 @@ mpl.figure.prototype._init_canvas = function () {
139141

140142
var canvas = (this.canvas = document.createElement('canvas'));
141143
canvas.classList.add('mpl-canvas');
142-
canvas.setAttribute('style', 'left: 0; top: 0; z-index: 0; outline: 0');
144+
canvas.setAttribute('style', 'box-sizing: content-box;');
143145

144146
this.context = canvas.getContext('2d');
145147

@@ -159,7 +161,7 @@ mpl.figure.prototype._init_canvas = function () {
159161
));
160162
rubberband_canvas.setAttribute(
161163
'style',
162-
'position: absolute; left: 0; top: 0; z-index: 1;'
164+
'box-sizing: content-box; position: absolute; left: 0; top: 0; z-index: 1;'
163165
);
164166

165167
var resizeObserver = new ResizeObserver(function (entries) {

lib/matplotlib/backends/web_backend/js/nbagg_mpl.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ mpl.figure.prototype._remove_fig_handler = function () {
176176
};
177177

178178
mpl.figure.prototype._root_extra_style = function (el) {
179+
el.style.boxSizing = 'content-box'; // override notebook setting of border-box.
179180
el.addEventListener('remove', this._remove_fig_handler);
180181
};
181182

0 commit comments

Comments
 (0)