Skip to content

Commit

Permalink
[BasicUI] Fix selection of color temperature near min and max
Browse files Browse the repository at this point in the history
Signed-off-by: Laurent Garnier <lg.hc@free.fr>
  • Loading branch information
lolodomo committed Nov 16, 2024
1 parent 45dd117 commit 20e5f3a
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions bundles/org.openhab.ui.basic/web-src/smarthome.js
Original file line number Diff line number Diff line change
Expand Up @@ -2266,8 +2266,9 @@
if (gradientColors !== "") {
_t.slider.style.background = "linear-gradient(to right, " + gradientColors + ")";
}
_t.slider.min = Math.round(min);
_t.slider.max = Math.round(max);
// Extend min/max to integers
_t.slider.min = Math.floor(min);
_t.slider.max = Math.ceil(max);

function setCorTemperature(value) {
if (isNaN(value)) {
Expand Down Expand Up @@ -2423,7 +2424,15 @@

_t.modalControl = new Colortemppicker(_t.modal.container, _t.min, _t.max, _t.value, _t.gradientColors,
function(valueKelvin) {
emitEvent(valueKelvin);
var
value = valueKelvin;

if (value < _t.min) {
value = _t.min;
} else if (value > _t.max) {
value = _t.max;
}
emitEvent(value);
}
);

Expand Down

0 comments on commit 20e5f3a

Please sign in to comment.