diff --git a/src/css/tabs/pid_tuning.less b/src/css/tabs/pid_tuning.less index a4764cfa6ab..c10cf8c6faa 100644 --- a/src/css/tabs/pid_tuning.less +++ b/src/css/tabs/pid_tuning.less @@ -732,6 +732,7 @@ } } .slidersWarning { + text-align: center; background: #ffa3a3; border: 1px solid red; font-weight: 600; diff --git a/src/js/tabs/motors.js b/src/js/tabs/motors.js index 4987f52f9d0..567abaf9a85 100644 --- a/src/js/tabs/motors.js +++ b/src/js/tabs/motors.js @@ -978,6 +978,12 @@ motors.initialize = async function (callback) { } }); + $('div.sliders input:not(.master)').on('input wheel', function (e) { + const slider = $(this); + + self.scrollSlider(slider, e); + }); + $('div.sliders input.master').on('input', function () { const val = $(this).val(); @@ -986,6 +992,12 @@ motors.initialize = async function (callback) { $('div.sliders input:not(:last):first').trigger('input'); }); + $('div.sliders input.master').on('input wheel', function (e) { + const slider = $(this); + + self.scrollSlider(slider, e); + }); + // check if motors are already spinning let motorsRunning = false; @@ -1316,6 +1328,25 @@ motors.cleanup = function (callback) { if (callback) callback(); }; +motors.scrollSlider = function(slider, e) { + if (slider.prop('disabled')) { + return; + } + + if (!e.originalEvent?.deltaY) { + return; + } + + e.preventDefault(); + + const step = 25; + const delta = e.originalEvent.deltaY > 0 ? 0 - step : step; + const val = parseInt(slider.val()) + delta; + const roundedVal = Math.round(val / step) * step; + slider.val(roundedVal); + slider.trigger('input'); +}; + TABS.motors = motors; export { motors, diff --git a/src/js/tabs/pid_tuning.js b/src/js/tabs/pid_tuning.js index d974d61746f..eb6d5fea130 100644 --- a/src/js/tabs/pid_tuning.js +++ b/src/js/tabs/pid_tuning.js @@ -2021,6 +2021,10 @@ pid_tuning.initialize = function (callback) { self.analyticsChanges['PidTuningSliders'] = "On"; }); + allPidTuningSliders.on('input wheel', function(e) { + self.scrollSlider($(this), e); + }); + // reset to middle with double click allPidTuningSliders.dblclick(function() { const slider = $(this); @@ -2118,6 +2122,10 @@ pid_tuning.initialize = function (callback) { } }); + allFilterTuningSliders.on('input wheel', function(e) { + self.scrollSlider($(this), e); + }); + // reset to middle with double click allFilterTuningSliders.dblclick(function() { const slider = $(this); @@ -2970,6 +2978,26 @@ pid_tuning.expertModeChanged = function(expertModeEnabled) { TuningSliders.setExpertMode(expertModeEnabled); }; +pid_tuning.scrollSlider = function(slider, e) { + if (!e.originalEvent?.deltaY) { + return; + } + + if (slider.prop('disabled')) { + return; + } + + e.preventDefault(); + + const step = parseFloat(slider.attr('step')); + const delta = e.originalEvent.deltaY > 0 ? 0 - step : step; + const preScrollSliderValue = isInt(slider.val()) ? parseInt(slider.val()) : parseFloat(slider.val()); + const sliderValue = (Math.floor(preScrollSliderValue * 100) + Math.floor(delta * 100)) / 100; + + slider.val(sliderValue); + slider.trigger('input'); +}; + TABS.pid_tuning = pid_tuning; export { pid_tuning, diff --git a/src/tabs/pid_tuning.html b/src/tabs/pid_tuning.html index a17d22a4c8a..dba638d04db 100644 --- a/src/tabs/pid_tuning.html +++ b/src/tabs/pid_tuning.html @@ -66,9 +66,6 @@