Skip to content

Commit 13508da

Browse files
committed
updatemenus: handle mouse wheel events
1 parent 9e3ac1b commit 13508da

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

src/components/updatemenus/scrollbox.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,8 @@ ScrollBox.prototype.enable = function enable() {
246246
.on('.drag', null)
247247
.call(onBarDrag);
248248
}
249+
250+
this.container.on('wheel', this._onBoxWheel.bind(this));
249251
}
250252

251253
// set initial position
@@ -279,6 +281,8 @@ ScrollBox.prototype.disable = function disable() {
279281
delete this._vbarYMin;
280282
delete this._vbarTranslateMax;
281283
}
284+
285+
this.container.on('wheel', null);
282286
};
283287

284288
/**
@@ -301,6 +305,26 @@ ScrollBox.prototype._onBoxDrag = function onBarDrag() {
301305
this.setTranslate(translateX, translateY);
302306
};
303307

308+
/**
309+
* Handles scroll box wheel events
310+
*
311+
* @method
312+
*/
313+
ScrollBox.prototype._onBoxWheel = function onBarWheel() {
314+
var translateX = this._translateX,
315+
translateY = this._translateY;
316+
317+
if(this._hbar) {
318+
translateX += d3.event.deltaY;
319+
}
320+
321+
if(this._vbar) {
322+
translateY += d3.event.deltaY;
323+
}
324+
325+
this.setTranslate(translateX, translateY);
326+
};
327+
304328
/**
305329
* Handles scroll bar drag events
306330
*

0 commit comments

Comments
 (0)