@@ -36,6 +36,25 @@ function ScrollBox(gd, container, id) {
3636 this . translateY = null ; // scrollbox vertical translation
3737 this . hbar = null ; // horizontal scrollbar D3 selection
3838 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+ } ) ;
3958}
4059
4160// scroll bar dimensions
@@ -219,11 +238,26 @@ ScrollBox.prototype.enable = function enable(position, translateX, translateY) {
219238 width : Math . ceil ( clipR ) - Math . floor ( clipL ) ,
220239 height : Math . ceil ( clipB ) - Math . floor ( clipT )
221240 } ) ;
241+
222242 this . container . call ( Drawing . setClipUrl , clipId ) ;
243+
244+ this . bg . attr ( {
245+ x : l ,
246+ y : t ,
247+ width : w ,
248+ height : h
249+ } ) ;
223250 }
224251 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 ) ;
225260 delete this . _clipRect ;
226- this . container . call ( Drawing . setClipUrl , null ) ;
227261 }
228262
229263 // set up drag listeners (if scroll bars are needed)
@@ -235,6 +269,8 @@ ScrollBox.prototype.enable = function enable(position, translateX, translateY) {
235269 . on ( 'drag' , this . _onBoxDrag . bind ( this ) ) ;
236270
237271 this . container
272+ . on ( 'wheel' , null )
273+ . on ( 'wheel' , this . _onBoxWheel . bind ( this ) )
238274 . on ( '.drag' , null )
239275 . call ( onBoxDrag ) ;
240276
@@ -256,8 +292,6 @@ ScrollBox.prototype.enable = function enable(position, translateX, translateY) {
256292 . on ( '.drag' , null )
257293 . call ( onBarDrag ) ;
258294 }
259-
260- this . container . on ( 'wheel' , this . _onBoxWheel . bind ( this ) ) ;
261295 }
262296
263297 // set scrollbox translation
@@ -271,8 +305,14 @@ ScrollBox.prototype.enable = function enable(position, translateX, translateY) {
271305 */
272306ScrollBox . prototype . disable = function disable ( ) {
273307 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 ) ;
276316 delete this . _clipRect ;
277317 }
278318
@@ -291,8 +331,6 @@ ScrollBox.prototype.disable = function disable() {
291331 delete this . _vbarYMin ;
292332 delete this . _vbarTranslateMax ;
293333 }
294-
295- this . container . on ( 'wheel' , null ) ;
296334} ;
297335
298336/**
0 commit comments