mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-22 16:56:35 +00:00
Fix gauge on ios 15.2 (#10992)
This commit is contained in:
parent
dced053ba2
commit
7b840527b5
@ -8,6 +8,10 @@ import { FrontendLocaleData } from "../data/translation";
|
|||||||
import { getValueInPercentage, normalize } from "../util/calculate";
|
import { getValueInPercentage, normalize } from "../util/calculate";
|
||||||
import { isSafari } from "../util/is_safari";
|
import { isSafari } from "../util/is_safari";
|
||||||
|
|
||||||
|
// Safari version 15.2 and up behaves differently than other Safari versions.
|
||||||
|
// https://github.com/home-assistant/frontend/issues/10766
|
||||||
|
const isSafari152 = isSafari && /Version\/15\.[^0-1]/.test(navigator.userAgent);
|
||||||
|
|
||||||
const getAngle = (value: number, min: number, max: number) => {
|
const getAngle = (value: number, min: number, max: number) => {
|
||||||
const percentage = getValueInPercentage(normalize(value, min, max), min, max);
|
const percentage = getValueInPercentage(normalize(value, min, max), min, max);
|
||||||
return (percentage * 180) / 100;
|
return (percentage * 180) / 100;
|
||||||
@ -113,7 +117,9 @@ export class Gauge extends LitElement {
|
|||||||
: undefined
|
: undefined
|
||||||
)}
|
)}
|
||||||
transform=${ifDefined(
|
transform=${ifDefined(
|
||||||
isSafari ? `rotate(${this._angle} 50 50)` : undefined
|
isSafari
|
||||||
|
? `rotate(${this._angle}${isSafari152 ? "" : " 50 50"})`
|
||||||
|
: undefined
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
`
|
`
|
||||||
@ -126,7 +132,9 @@ export class Gauge extends LitElement {
|
|||||||
: undefined
|
: undefined
|
||||||
)}
|
)}
|
||||||
transform=${ifDefined(
|
transform=${ifDefined(
|
||||||
isSafari ? `rotate(${this._angle} 50 50)` : undefined
|
isSafari
|
||||||
|
? `rotate(${this._angle}${isSafari152 ? "" : " 50 50"})`
|
||||||
|
: undefined
|
||||||
)}
|
)}
|
||||||
>`
|
>`
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user