Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix for figure resizing in webagg#3341

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Closed
Closed
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 39 additions & 6 deletionslib/matplotlib/backends/web_backend/mpl.js
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -40,7 +40,7 @@ mpl.figure = function(figure_id, websocket, ondownload, parent_element) {
this.rubberband_context = undefined;
this.format_dropdown = undefined;

this.focus_on_mousover = false;
this.focus_on_mouseover = false;

this.root = $('<div/>');
this.root.attr('style', 'display: inline-block');
Expand DownExpand Up@@ -89,9 +89,6 @@ mpl.figure.prototype._init_canvas = function() {
var fig = this;

var canvas_div = $('<div/>');
canvas_div.resizable({ resize: mpl.debounce_resize(
function(event, ui) { fig.request_resize(ui.size.width, ui.size.height); }
, 50)});

canvas_div.attr('style', 'position: relative; clear: both;');
this.root.append(canvas_div);
Expand All@@ -109,8 +106,44 @@ mpl.figure.prototype._init_canvas = function() {

var rubberband = $('<canvas/>');
rubberband.attr('style', "position: absolute; left: 0; top: 0; z-index: 1;")

var ignore_mouse_events = false;

// The if statement below should just be implemented directly in CSS...
if (!$("head").hasClass("boxme"))
{
$("<style type='text/css'> .boxme { background-color: lightgray; border: 1px solid gray;} </style>").appendTo("head");
}

canvas_div.resizable({
start: function(event, ui) {
ignore_mouse_events = true;
ctx = fig.context;
var canvas = ctx.canvas;
canvas.blur(); // removes focus if focused (may need more work?)
canvas_div.addClass("boxme");

/// Clearing the canvas
// Store the current transformation matrix
ctx.save();
// Use the identity matrix while clearing the canvas
ctx.setTransform(1, 0, 0, 1, 0, 0);
ctx.clearRect(0, 0, canvas.width, canvas.height);
// Restore the transform
ctx.restore();
},
stop: function(event, ui) {
ignore_mouse_events = false;
fig.request_resize(ui.size.width, ui.size.height);
canvas_div.removeClass("boxme");
},
});

function mouse_event_fn(event) {
return fig.mouse_event(event, event['data']);
if (ignore_mouse_events == false)
{
return fig.mouse_event(event, event['data']);
}
}
rubberband.mousedown('button_press', mouse_event_fn);
rubberband.mouseup('button_release', mouse_event_fn);
Expand DownExpand Up@@ -379,7 +412,7 @@ mpl.findpos = function(e) {
};

mpl.figure.prototype.mouse_event = function(event, name) {
var canvas_pos = mpl.findpos(event)
var canvas_pos = mpl.findpos(event);

if (this.focus_on_mouseover && name === 'motion_notify')
{
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp