@@ -41,7 +41,7 @@ export class LinearProgressBase extends LitElement {
4141 @internalProperty ( ) protected styleSecondaryHalf = '' ;
4242 @internalProperty ( ) protected styleSecondaryFull = '' ;
4343 @internalProperty ( ) protected animationReady = true ;
44-
44+ @ internalProperty ( ) protected closedAnimationOff = false ;
4545 protected resizeObserver : ResizeObserver | null = null ;
4646
4747 connectedCallback ( ) {
@@ -59,6 +59,7 @@ export class LinearProgressBase extends LitElement {
5959 /** @classMap */
6060 const classes = {
6161 'mdc-linear-progress--closed' : this . closed ,
62+ 'mdc-linear-progress--closed-animation-off' : this . closedAnimationOff ,
6263 'mdc-linear-progress--indeterminate' : this . indeterminate ,
6364 'mdc-linear-progress--reversed' : this . reverse ,
6465 // needed for controller-less render
@@ -101,7 +102,8 @@ export class LinearProgressBase extends LitElement {
101102 aria-valuemin="0"
102103 aria-valuemax="1"
103104 aria-valuenow=${
104- ifDefined ( this . indeterminate ? undefined : this . progress ) } >
105+ ifDefined ( this . indeterminate ? undefined : this . progress ) }
106+ @transitionend=${ this . syncClosedState } >
105107 < div class ="mdc-linear-progress__buffer ">
106108 < div
107109 class ="mdc-linear-progress__buffer-bar "
@@ -120,12 +122,29 @@ export class LinearProgressBase extends LitElement {
120122 </ div > ` ;
121123 }
122124
125+ update ( changedProperties : Map < string , string > ) {
126+ // - When showing the indicator, enable animations immediately.
127+ // - On first render, disable the animation immediately.
128+ // - For normal calls to hide the component, let transitionend event trigger
129+ // disabling of animations instead (see render method), so that animation
130+ // does not jump in the middle of fade out.
131+ if ( changedProperties . has ( 'closed' ) &&
132+ ( ! this . closed || changedProperties . get ( 'closed' ) === undefined ) ) {
133+ this . syncClosedState ( ) ;
134+ }
135+ super . update ( changedProperties ) ;
136+ }
137+
123138 async firstUpdated ( changed : PropertyValues ) {
124139 super . firstUpdated ( changed ) ;
125140
126141 this . attachResizeObserver ( ) ;
127142 }
128143
144+ private syncClosedState ( ) {
145+ this . closedAnimationOff = this . closed ;
146+ }
147+
129148 protected updated ( changed : PropertyValues ) {
130149 // restart animation for timing if reverse changed and is indeterminate.
131150 // don't restart here if indeterminate has changed as well because we don't
0 commit comments