@@ -109,9 +109,6 @@ mpl.figure.prototype._init_canvas = function() {
109
109
var fig = this ;
110
110
111
111
var canvas_div = $ ( '<div/>' ) ;
112
- canvas_div . resizable ( { resize : mpl . debounce_resize (
113
- function ( event , ui ) { fig . request_resize ( ui . size . width , ui . size . height ) ; }
114
- , 50 ) } ) ;
115
112
116
113
canvas_div . attr ( 'style' , 'position: relative; clear: both; outline: 0' ) ;
117
114
@@ -134,9 +131,27 @@ mpl.figure.prototype._init_canvas = function() {
134
131
135
132
var rubberband = $ ( '<canvas/>' ) ;
136
133
rubberband . attr ( 'style' , "position: absolute; left: 0; top: 0; z-index: 1;" )
134
+
135
+ var pass_mouse_events = true ;
136
+
137
+ canvas_div . resizable ( {
138
+ start : function ( event , ui ) {
139
+ pass_mouse_events = false ;
140
+ } ,
141
+ resize : function ( event , ui ) {
142
+ fig . request_resize ( ui . size . width , ui . size . height ) ;
143
+ } ,
144
+ stop : function ( event , ui ) {
145
+ pass_mouse_events = true ;
146
+ fig . request_resize ( ui . size . width , ui . size . height ) ;
147
+ } ,
148
+ } ) ;
149
+
137
150
function mouse_event_fn ( event ) {
138
- return fig . mouse_event ( event , event [ 'data' ] ) ;
151
+ if ( pass_mouse_events )
152
+ return fig . mouse_event ( event , event [ 'data' ] ) ;
139
153
}
154
+
140
155
rubberband . mousedown ( 'button_press' , mouse_event_fn ) ;
141
156
rubberband . mouseup ( 'button_release' , mouse_event_fn ) ;
142
157
// Throttle sequential mouse events to 1 every 20ms.
@@ -489,19 +504,3 @@ mpl.figure.prototype.toolbar_button_onclick = function(name) {
489
504
mpl . figure . prototype . toolbar_button_onmouseover = function ( tooltip ) {
490
505
this . message . textContent = tooltip ;
491
506
} ;
492
-
493
- mpl . debounce_event = function ( func , time ) {
494
- var timer ;
495
- return function ( event ) {
496
- clearTimeout ( timer ) ;
497
- timer = setTimeout ( function ( ) { func ( event ) ; } , time ) ;
498
- } ;
499
- }
500
-
501
- mpl . debounce_resize = function ( func , time ) {
502
- var timer ;
503
- return function ( event , ui ) {
504
- clearTimeout ( timer ) ;
505
- timer = setTimeout ( function ( ) { func ( event , ui ) ; } , time ) ;
506
- } ;
507
- }
0 commit comments