* Resizes the dialog container. * @param {!./view.View} view * @param {number} height * @param {boolean=} animated * @return {?Promise}
(view, height, animated = true)
| 11157 | * @return {?Promise} |
| 11158 | */ |
| 11159 | resizeView(view, height, animated = true) { |
| 11160 | if (this.view_ != view) { |
| 11161 | return null; |
| 11162 | } |
| 11163 | const newHeight = this.getMaxAllowedHeight_(height); |
| 11164 | |
| 11165 | // Uniquely identify this animation. |
| 11166 | // This lets callbacks abandon stale animations. |
| 11167 | const animationNumber = ++this.animationNumber_; |
| 11168 | const isStale = () => { |
| 11169 | return animationNumber !== this.animationNumber_; |
| 11170 | }; |
| 11171 | |
| 11172 | let animating; |
| 11173 | if (animated) { |
| 11174 | const oldHeight = this.getElement().offsetHeight; |
| 11175 | if (newHeight >= oldHeight) { |
| 11176 | // Expand. |
| 11177 | animating = this.animate_(() => { |
| 11178 | if (isStale()) { |
| 11179 | return Promise.resolve(); |
| 11180 | } |
| 11181 | |
| 11182 | const immediateStyles = { |
| 11183 | 'height': `${newHeight}px`, |
| 11184 | }; |
| 11185 | if (!this.shouldPositionCenter_()) { |
| 11186 | immediateStyles['transform'] = `translateY(${ |
| 11187 | newHeight - oldHeight |
| 11188 | }px)`; |
| 11189 | } |
| 11190 | setImportantStyles$1(this.getElement(), immediateStyles); |
| 11191 | |
| 11192 | return transition$1( |
| 11193 | this.getElement(), |
| 11194 | { |
| 11195 | 'transform': this.getDefaultTranslateY_(), |
| 11196 | }, |
| 11197 | 300, |
| 11198 | 'ease-out' |
| 11199 | ); |
| 11200 | }); |
| 11201 | } else { |
| 11202 | // Collapse. |
| 11203 | animating = this.animate_(() => { |
| 11204 | const transitionPromise = isStale() |
| 11205 | ? Promise.resolve() |
| 11206 | : transition$1( |
| 11207 | this.getElement(), |
| 11208 | { |
| 11209 | 'transform': this.shouldPositionCenter_() |
| 11210 | ? this.getDefaultTranslateY_() |
| 11211 | : `translateY(${oldHeight - newHeight}px)`, |
| 11212 | }, |
| 11213 | 300, |
| 11214 | 'ease-out' |
| 11215 | ); |
| 11216 | return transitionPromise.then(() => { |
no test coverage detected