Skip to content
This repository has been archived by the owner on Feb 12, 2022. It is now read-only.

Commit

Permalink
Removing mouse scroll wheel functionality completely
Browse files Browse the repository at this point in the history
If you would like mouse scroll wheel functionality added back in, please see what was removed in this commit.
  • Loading branch information
interactivellama committed May 25, 2016
1 parent 7059ddd commit 78d52df
Showing 1 changed file with 2 additions and 47 deletions.
49 changes: 2 additions & 47 deletions js/spinbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,6 @@
this.$element.on('keydown.fu.spinbox', this.$input, $.proxy(this.keydown, this));
this.$element.on('keyup.fu.spinbox', this.$input, $.proxy(this.keyup, this));

if (this.options.enableMouseWheelScroll) {
this.bindMousewheelListeners();
this.mousewheelTimeout = {};
}

if (this.options.hold) {
this.$element.on('mousedown.fu.spinbox', '.spinbox-up', $.proxy(function () {
this.startSpin(true);
Expand Down Expand Up @@ -358,47 +353,8 @@
if (keyCode === 38 || keyCode === 40) {
this.triggerChangedEvent();
}
},

bindMousewheelListeners: function bindMousewheelListeners() {
var inputEl = this.$input.get(0);
if (inputEl.addEventListener) {
//IE 9, Chrome, Safari, Opera
inputEl.addEventListener('mousewheel', $.proxy(this.mousewheelHandler, this), false);
// Firefox
inputEl.addEventListener('DOMMouseScroll', $.proxy(this.mousewheelHandler, this), false);
} else {
// IE <9
inputEl.attachEvent('onmousewheel', $.proxy(this.mousewheelHandler, this));
}
},

mousewheelHandler: function mousewheelHandler(event) {
if (!this.options.disabled) {
var e = window.event || event;// old IE support
var delta = Math.max(-1, Math.min(1, (e.wheelDelta || -e.detail)));
var self = this;

clearTimeout(this.mousewheelTimeout);
this.mousewheelTimeout = setTimeout(function () {
self.triggerChangedEvent();
}, 300);

if (delta < 0) {
this.step(true);
} else {
this.step(false);
}

if (e.preventDefault) {
e.preventDefault();
} else {
e.returnValue = false;
}

return false;
}
}

};


Expand Down Expand Up @@ -438,8 +394,7 @@
units: [],
decimalMark: '.',
defaultUnit: '',
limitToStep: false,
enableMouseWheelScroll: false
limitToStep: false
};

$.fn.spinbox.Constructor = Spinbox;
Expand Down

0 comments on commit 78d52df

Please sign in to comment.