* Handler for 'wheel' event * * @param {WheelEvent} e
(e)
| 7668 | * @param {WheelEvent} e |
| 7669 | */ |
| 7670 | _onWheel(e) { |
| 7671 | if (this.formulaMode) { |
| 7672 | return; |
| 7673 | } |
| 7674 | |
| 7675 | if (this.settings.readOnly || this.domElement.readOnly || this.domElement.disabled) { |
| 7676 | // Do not allow scrolling in a readonly element (fix issue #541) |
| 7677 | return; |
| 7678 | } |
| 7679 | |
| 7680 | if (this.settings.modifyValueOnWheel) { |
| 7681 | if (this.settings.wheelOn === AutoNumeric.options.wheelOn.focus) { |
| 7682 | if (this.isFocused) { |
| 7683 | if (!e.shiftKey) { |
| 7684 | this.wheelAction(e); |
| 7685 | } |
| 7686 | } else if (e.shiftKey) { |
| 7687 | this.wheelAction(e); |
| 7688 | } |
| 7689 | } else if (this.settings.wheelOn === AutoNumeric.options.wheelOn.hover) { |
| 7690 | if (!e.shiftKey) { |
| 7691 | this.wheelAction(e); |
| 7692 | } else { |
| 7693 | // Note: When not `defaultPrevented`, Shift + mouse wheel is reserved by the browsers for horizontal scrolling. |
| 7694 | // Hence, using the Shift key with the `wheelOn` 'hover' option will only scroll the page if we prevent the default behavior |
| 7695 | e.preventDefault(); // Do not scroll horizontally |
| 7696 | |
| 7697 | // Scroll vertically |
| 7698 | window.scrollBy(0, AutoNumericHelper.isNegativeStrict(String(e.deltaY))?-50:50); // `e.deltaY` is usually too small compared to how the page is scrolled. That's why we use a fixed offset. |
| 7699 | } |
| 7700 | } else { |
| 7701 | AutoNumericHelper.throwError('Unknown `wheelOn` option.'); |
| 7702 | } |
| 7703 | } |
| 7704 | } |
| 7705 | |
| 7706 | /** |
| 7707 | * Increment or decrement the element value according to the `wheelStep` option chosen |
no test coverage detected