Skip to content

Commit

Permalink
fix(loading): update circle height incase loader is rendered hidden (T…
Browse files Browse the repository at this point in the history
  • Loading branch information
emoralesb05 authored Jan 4, 2018
1 parent 287f9d5 commit f236083
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/platform/core/loading/loading.component.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, ViewChild, TemplateRef, ChangeDetectorRef, ChangeDetectionStrategy, ElementRef } from '@angular/core';
import { Component, ViewChild, TemplateRef, ChangeDetectorRef, ChangeDetectionStrategy, ElementRef, DoCheck } from '@angular/core';
import { AnimationEvent } from '@angular/animations';
import { TemplatePortal } from '@angular/cdk/portal';
import { Subject } from 'rxjs/Subject';
Expand Down Expand Up @@ -37,7 +37,7 @@ export const TD_CIRCLE_DIAMETER: number = 100;
TdFadeInOutAnimation(),
],
})
export class TdLoadingComponent {
export class TdLoadingComponent implements DoCheck {

private _animationIn: Subject<any> = new Subject<any>();
private _animationOut: Subject<any> = new Subject<any>();
Expand Down Expand Up @@ -101,6 +101,17 @@ export class TdLoadingComponent {
constructor(private _elementRef: ElementRef,
private _changeDetectorRef: ChangeDetectorRef) {}

ngDoCheck(): void {
// When overlay is used and the host width has a value greater than 1px
// set the circle diameter when possible incase the loading component was rendered in a hidden state
if (this.isOverlay() && this._hostHeight() > 1) {
if (this.animation) {
this._setCircleDiameter();
this._changeDetectorRef.markForCheck();
}
}
}

getHeight(): string {
// Ignore height if style is `overlay` or `fullscreen`.
// Add height if child elements have a height and style is `none`, else return default height.
Expand Down

0 comments on commit f236083

Please sign in to comment.