Cover position tile feature (#16110)

* wip

* css + transtations

* Update types.ts

rollback changes done by VS Code

* fix

* Inverted slider

---------

Co-authored-by: Paul Bottein <paul.bottein@gmail.com>
This commit is contained in:
Tomasz
2023-08-18 10:40:41 +02:00
committed by GitHub
parent 6e27fbe10f
commit 705b6aeb4b
7 changed files with 139 additions and 4 deletions

View File

@@ -43,6 +43,9 @@ export class HaControlSlider extends LitElement {
@property({ type: Boolean, attribute: "show-handle" })
public showHandle = false;
@property({ type: Boolean, attribute: "inverted" })
public inverted = false;
@property({ type: Number })
public value?: number;
@@ -61,11 +64,16 @@ export class HaControlSlider extends LitElement {
public pressed = false;
valueToPercentage(value: number) {
return (this.boundedValue(value) - this.min) / (this.max - this.min);
const percentage =
(this.boundedValue(value) - this.min) / (this.max - this.min);
return this.inverted ? 1 - percentage : percentage;
}
percentageToValue(value: number) {
return (this.max - this.min) * value + this.min;
percentageToValue(percentage: number) {
return (
(this.max - this.min) * (this.inverted ? 1 - percentage : percentage) +
this.min
);
}
steppedValue(value: number) {