Skip to content

Commit 4de5e74

Browse files
committed
fix(progress): prevent unnecessary animation to run when not visible
Progress has an infinite animation on `<div class="dots">`. `.dots` is only visible when `value` < `max` or `buffer` < `max`. But the animation runs in any case.
1 parent 839667d commit 4de5e74

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

progress/internal/linear-progress.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import {html} from 'lit';
88
import {property} from 'lit/decorators.js';
99
import {styleMap} from 'lit/directives/style-map.js';
10+
import {when} from 'lit/directives/when.js';
1011

1112
import {Progress} from './progress.js';
1213

@@ -33,9 +34,10 @@ export class LinearProgress extends Progress {
3334
(this.indeterminate ? 1 : this.buffer / this.max) * 100
3435
}%)`,
3536
};
36-
37+
// only display dots when visible - this prevents invisible infinite animation
38+
const showDots = !this.indeterminate && (this.buffer >= this.max || this.value >= this.max) ;
3739
return html`
38-
<div class="dots"></div>
40+
${when(showDots, () => html`<div class="dots"></div>`)}
3941
<div class="inactive-track" style=${styleMap(dotStyles)}></div>
4042
<div class="bar primary-bar" style=${styleMap(progressStyles)}>
4143
<div class="bar-inner"></div>

0 commit comments

Comments
 (0)