Skip to content

Commit 79ad9db

Browse files
authored
Disable graph resize animation for general resizing (#27816)
1 parent 9814533 commit 79ad9db

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/components/chart/ha-chart-base.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ export const MIN_TIME_BETWEEN_UPDATES = 60 * 5 * 1000;
3535
const LEGEND_OVERFLOW_LIMIT = 10;
3636
const LEGEND_OVERFLOW_LIMIT_MOBILE = 6;
3737
const DOUBLE_TAP_TIME = 300;
38-
const RESIZE_ANIMATION_DURATION = 250;
3938

4039
export type CustomLegendOption = ECOption["legend"] & {
4140
type: "custom";
@@ -91,6 +90,8 @@ export class HaChartBase extends LitElement {
9190

9291
private _shouldResizeChart = false;
9392

93+
private _resizeAnimationDuration?: number;
94+
9495
// @ts-ignore
9596
private _resizeController = new ResizeController(this, {
9697
callback: () => {
@@ -214,6 +215,7 @@ export class HaChartBase extends LitElement {
214215
) {
215216
// custom legend changes may require a resize to layout properly
216217
this._shouldResizeChart = true;
218+
this._resizeAnimationDuration = 250;
217219
}
218220
} else if (this._isTouchDevice && changedProps.has("_isZoomed")) {
219221
chartOptions.dataZoom = this._getDataZoomConfig();
@@ -977,11 +979,14 @@ export class HaChartBase extends LitElement {
977979
private _handleChartRenderFinished = () => {
978980
if (this._shouldResizeChart) {
979981
this.chart?.resize({
980-
animation: this._reducedMotion
981-
? undefined
982-
: { duration: RESIZE_ANIMATION_DURATION },
982+
animation:
983+
this._reducedMotion ||
984+
typeof this._resizeAnimationDuration !== "number"
985+
? undefined
986+
: { duration: this._resizeAnimationDuration },
983987
});
984988
this._shouldResizeChart = false;
989+
this._resizeAnimationDuration = undefined;
985990
}
986991
};
987992

0 commit comments

Comments
 (0)