Skip to content

Add Support for scroll_event in WebAgg and NbAgg [backport to 1.4.x] #3968

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 22 commits into from
Jan 11, 2015
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Add scroll event handling to webagg backend
Conflicts:
	lib/matplotlib/backends/backend_webagg_core.py

Conflicts:
	lib/matplotlib/backends/backend_webagg_core.py
	lib/matplotlib/backends/web_backend/mpl.js
  • Loading branch information
blink1073 committed Jan 11, 2015
commit ac51ebc0a9c14046f8c6b4555a213def0788d359
26 changes: 26 additions & 0 deletions lib/matplotlib/backends/web_backend/mpl.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ mpl.figure.prototype._init_canvas = function() {
// Throttle sequential mouse events to 1 every 20ms.
rubberband.mousemove('motion_notify', mouse_event_fn);

<<<<<<< HEAD
rubberband.mouseenter('figure_enter', mouse_event_fn);
rubberband.mouseleave('figure_leave', mouse_event_fn);

Expand All @@ -152,6 +153,31 @@ mpl.figure.prototype._init_canvas = function() {
event.step = event.deltaY / 3.
mouse_event_fn(event);
});
=======

rubberband.mouseenter('figure_enter', mouse_event_fn);
rubberband.mouseleave('figure_leave', mouse_event_fn);

function scroll_fn(event) {
event['data'] = 'scroll'
// http://www.adomas.org/javascript-mouse-wheel/
if (event.wheelDelta) { /* IE/Opera. */
event.step = event.wheelDelta/120;
} else if (event.detail) { /** Mozilla case. */
/** In Mozilla, sign of delta is different than in IE.
* Also, delta is multiple of 3.
*/
event.step = -event.detail/3;
}
mouse_event_fn(event)
}
// Initialization code.
if (window.addEventListener)
/** DOMMouseScroll is for mozilla. */
window.addEventListener('DOMMouseScroll', scroll_fn, false);
/** IE/Opera. */
window.onmousewheel = document.onmousewheel = scroll_fn;
>>>>>>> fe99b32... Add scroll event handling to webagg backend

canvas_div.append(canvas);
canvas_div.append(rubberband);
Expand Down