MCPcopy Index your code
hub / github.com/autoNumeric/autoNumeric / _onWheel

Method _onWheel

src/AutoNumeric.js:7670–7704  ·  view source on GitHub ↗

* Handler for 'wheel' event * * @param {WheelEvent} e

(e)

Source from the content-addressed store, hash-verified

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

Callers 1

_createEventListenersMethod · 0.95

Calls 3

wheelActionMethod · 0.95
isNegativeStrictMethod · 0.80
throwErrorMethod · 0.80

Tested by

no test coverage detected