@@ -36,6 +36,25 @@ function ScrollBox(gd, container, id) {
36
36
this . translateY = null ; // scrollbox vertical translation
37
37
this . hbar = null ; // horizontal scrollbar D3 selection
38
38
this . vbar = null ; // vertical scrollbar D3 selection
39
+
40
+ // <rect> element to capture pointer events
41
+ this . bg = this . container . selectAll ( 'rect.scrollbox-bg' ) . data ( [ 0 ] ) ;
42
+
43
+ this . bg . exit ( )
44
+ . on ( '.drag' , null )
45
+ . on ( 'wheel' , null )
46
+ . remove ( ) ;
47
+
48
+ this . bg . enter ( ) . append ( 'rect' )
49
+ . classed ( 'scrollbox-bg' , true )
50
+ . style ( 'pointer-events' , 'all' )
51
+ . attr ( {
52
+ opacity : 0 ,
53
+ x : 0 ,
54
+ y : 0 ,
55
+ width : 0 ,
56
+ height : 0
57
+ } ) ;
39
58
}
40
59
41
60
// scroll bar dimensions
@@ -219,11 +238,26 @@ ScrollBox.prototype.enable = function enable(position, translateX, translateY) {
219
238
width : Math . ceil ( clipR ) - Math . floor ( clipL ) ,
220
239
height : Math . ceil ( clipB ) - Math . floor ( clipT )
221
240
} ) ;
241
+
222
242
this . container . call ( Drawing . setClipUrl , clipId ) ;
243
+
244
+ this . bg . attr ( {
245
+ x : l ,
246
+ y : t ,
247
+ width : w ,
248
+ height : h
249
+ } ) ;
223
250
}
224
251
else {
252
+ this . bg . attr ( {
253
+ width : 0 ,
254
+ height : 0
255
+ } ) ;
256
+ this . container
257
+ . on ( 'wheel' , null )
258
+ . on ( '.drag' , null )
259
+ . call ( Drawing . setClipUrl , null ) ;
225
260
delete this . _clipRect ;
226
- this . container . call ( Drawing . setClipUrl , null ) ;
227
261
}
228
262
229
263
// set up drag listeners (if scroll bars are needed)
@@ -235,6 +269,8 @@ ScrollBox.prototype.enable = function enable(position, translateX, translateY) {
235
269
. on ( 'drag' , this . _onBoxDrag . bind ( this ) ) ;
236
270
237
271
this . container
272
+ . on ( 'wheel' , null )
273
+ . on ( 'wheel' , this . _onBoxWheel . bind ( this ) )
238
274
. on ( '.drag' , null )
239
275
. call ( onBoxDrag ) ;
240
276
@@ -256,8 +292,6 @@ ScrollBox.prototype.enable = function enable(position, translateX, translateY) {
256
292
. on ( '.drag' , null )
257
293
. call ( onBarDrag ) ;
258
294
}
259
-
260
- this . container . on ( 'wheel' , this . _onBoxWheel . bind ( this ) ) ;
261
295
}
262
296
263
297
// set scrollbox translation
@@ -271,8 +305,14 @@ ScrollBox.prototype.enable = function enable(position, translateX, translateY) {
271
305
*/
272
306
ScrollBox . prototype . disable = function disable ( ) {
273
307
if ( this . hbar || this . vbar ) {
274
- this . container . call ( Drawing . setClipUrl , null ) ;
275
- this . container . on ( '.drag' , null ) ;
308
+ this . bg . attr ( {
309
+ width : 0 ,
310
+ height : 0
311
+ } ) ;
312
+ this . container
313
+ . on ( 'wheel' , null )
314
+ . on ( '.drag' , null )
315
+ . call ( Drawing . setClipUrl , null ) ;
276
316
delete this . _clipRect ;
277
317
}
278
318
@@ -291,8 +331,6 @@ ScrollBox.prototype.
627F
disable = function disable() {
291
331
delete this . _vbarYMin ;
292
332
delete this . _vbarTranslateMax ;
293
333
}
294
-
295
- this . container . on ( 'wheel' , null ) ;
296
334
} ;
297
335
298
336
/**
0 commit comments