Skip to content

Commit

Permalink
fix(modals): fixed modals fade in animation
Browse files Browse the repository at this point in the history
fixes #687
  • Loading branch information
valorkin committed Jul 18, 2016
1 parent 7277e1a commit 2b95c95
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 11 deletions.
38 changes: 27 additions & 11 deletions components/modal/modal-backdrop.component.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import {Component, ElementRef} from '@angular/core';
import {NgClass} from '@angular/common';
import {Component, ElementRef, Renderer} from '@angular/core';
import {ClassName} from './modal-options.class';

export class ModalBackdropOptions {
Expand All @@ -12,20 +11,37 @@ export class ModalBackdropOptions {

@Component({
selector: 'bs-modal-backdrop',
directives: [NgClass],
template: `
<div class="${ClassName.BACKDROP}"
[class.${ClassName.IN}]="isShown"
[class.${ClassName.FADE}]="isAnimated"></div>`
template: '',
host: {'class': `${ClassName.BACKDROP}`}
})
export class ModalBackdropComponent {
public isAnimated:boolean = true;
public isShown:boolean = false;
public get isAnimated():boolean{
return this._isAnimated;
}

public set isAnimated(value:boolean) {
this._isAnimated = value;
this.renderer.setElementClass(this.element.nativeElement, `${ClassName.FADE}`, value);
}

public get isShown():boolean{
return this._isShown;
}

public set isShown(value:boolean) {
this._isShown = value;
this.renderer.setElementClass(this.element.nativeElement, `${ClassName.IN}`, value);
}

public element:ElementRef;
public renderer: Renderer;

private _isAnimated:boolean;
private _isShown:boolean = false;

public constructor(options:ModalBackdropOptions, element:ElementRef) {
this.isAnimated = options.animate;
public constructor(options:ModalBackdropOptions, element:ElementRef, renderer: Renderer) {
this.element = element;
this.renderer = renderer;
this.isAnimated = options.animate !== false;
}
}
1 change: 1 addition & 0 deletions tslint.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"extends": "tslint-config-valorsoft",
"rulesDirectory": "./node_modules/codelyzer",
"rules": {
"use-host-property-decorator": false,
"component-selector-name": [false, ""],
"no-constructor-vars": false,
"ordered-imports": false,
Expand Down

0 comments on commit 2b95c95

Please sign in to comment.