Skip to content

Commit

Permalink
fix(theme): remove a fixed content height (#882)
Browse files Browse the repository at this point in the history
Closes #836
  • Loading branch information
lexzhukov authored and nnixaa committed Oct 15, 2018
1 parent de18e9f commit a85eaf2
Showing 1 changed file with 2 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
Component,
ChangeDetectionStrategy,
Host,
ElementRef,
ChangeDetectorRef,
OnInit,
OnDestroy,
Expand All @@ -32,9 +31,7 @@ const accordionItemBodyTrigger = trigger('accordionItemBody', [
style({
overflow: 'hidden',
visibility: 'visible',
height: '{{ contentHeight }}',
}),
{ params: { contentHeight: '1rem' } },
),
transition('collapsed => expanded', animate('100ms ease-in')),
transition('expanded => collapsed', animate('100ms ease-out')),
Expand All @@ -46,7 +43,7 @@ const accordionItemBodyTrigger = trigger('accordionItemBody', [
@Component({
selector: 'nb-accordion-item-body',
template: `
<div [@accordionItemBody]="{ value: state, params: { contentHeight: contentHeight } }">
<div [@accordionItemBody]="{ value: state }">
<div class="item-body">
<ng-content></ng-content>
</div>
Expand All @@ -56,23 +53,15 @@ const accordionItemBodyTrigger = trigger('accordionItemBody', [
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class NbAccordionItemBodyComponent implements OnInit, OnDestroy {

contentHeight: string;

private alive: boolean = true;

constructor(
@Host() private accordionItem: NbAccordionItemComponent,
private el: ElementRef,
private cd: ChangeDetectorRef) {
}
constructor(@Host() private accordionItem: NbAccordionItemComponent, private cd: ChangeDetectorRef) {}

get state(): string {
return this.accordionItem.collapsed ? 'collapsed' : 'expanded';
}

ngOnInit() {
this.contentHeight = `${this.el.nativeElement.clientHeight}px`;
this.accordionItem.accordionItemInvalidate
.pipe(takeWhile(() => this.alive))
.subscribe(() => this.cd.markForCheck());
Expand Down

0 comments on commit a85eaf2

Please sign in to comment.