mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-26 18:56:39 +00:00
Don't wait for slider release to update color temp (#15914)
This commit is contained in:
parent
8ea350a488
commit
1b2eaedba0
@ -11,6 +11,7 @@ import {
|
|||||||
PropertyValues,
|
PropertyValues,
|
||||||
} from "lit";
|
} from "lit";
|
||||||
import { customElement, property, state } from "lit/decorators";
|
import { customElement, property, state } from "lit/decorators";
|
||||||
|
import { throttle } from "../../../../common/util/throttle";
|
||||||
import "../../../../components/ha-button-toggle-group";
|
import "../../../../components/ha-button-toggle-group";
|
||||||
import "../../../../components/ha-color-picker";
|
import "../../../../components/ha-color-picker";
|
||||||
import "../../../../components/ha-control-slider";
|
import "../../../../components/ha-control-slider";
|
||||||
@ -297,17 +298,26 @@ class MoreInfoViewLightColorPicker extends LitElement {
|
|||||||
private _ctSliderMoved(ev: CustomEvent) {
|
private _ctSliderMoved(ev: CustomEvent) {
|
||||||
const ct = ev.detail.value;
|
const ct = ev.detail.value;
|
||||||
|
|
||||||
if (isNaN(ct)) {
|
if (isNaN(ct) || this._ctSliderValue === ct) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this._ctSliderValue = ct;
|
this._ctSliderValue = ct;
|
||||||
|
|
||||||
|
this._throttleUpdateColorTemp();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private _throttleUpdateColorTemp = throttle(() => {
|
||||||
|
this.hass.callService("light", "turn_on", {
|
||||||
|
entity_id: this.stateObj!.entity_id,
|
||||||
|
color_temp_kelvin: this._ctSliderValue,
|
||||||
|
});
|
||||||
|
}, 500);
|
||||||
|
|
||||||
private _ctSliderChanged(ev: CustomEvent) {
|
private _ctSliderChanged(ev: CustomEvent) {
|
||||||
const ct = ev.detail.value;
|
const ct = ev.detail.value;
|
||||||
|
|
||||||
if (isNaN(ct)) {
|
if (isNaN(ct) || this._ctSliderValue === ct) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user