diff --git a/src/dat/controllers/NumberControllerBox.js b/src/dat/controllers/NumberControllerBox.js index 64cb003d..9ddc8f82 100644 --- a/src/dat/controllers/NumberControllerBox.js +++ b/src/dat/controllers/NumberControllerBox.js @@ -42,6 +42,8 @@ class NumberControllerBox extends NumberController { const _this = this; + const mousewheelevt = (/Firefox/i.test(navigator.userAgent)) ? 'DOMMouseScroll' : 'mousewheel'; + /** * {Number} Previous mouse y position * @ignore @@ -72,6 +74,12 @@ class NumberControllerBox extends NumberController { prevY = e.clientY; } + function onMouseWheel(e) { + e.preventDefault(); + const direction = ((e.deltaY || -e.wheelDelta || e.detail) >> 10) || 1; + _this.setValue(_this.getValue() + direction * _this.__impliedStep); + } + function onMouseUp() { dom.unbind(window, 'mousemove', onMouseDrag); dom.unbind(window, 'mouseup', onMouseUp); @@ -92,6 +100,7 @@ class NumberControllerBox extends NumberController { dom.bind(this.__input, 'change', onChange); dom.bind(this.__input, 'blur', onBlur); dom.bind(this.__input, 'mousedown', onMouseDown); + dom.bind(this.__input, mousewheelevt, onMouseWheel); dom.bind(this.__input, 'keydown', function(e) { // When pressing enter, you can be as precise as you want. const step = _this.__step || 1;