Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(modal): ModalDirective: config.animated = false is ignored #3137

Closed
flensrocker opened this issue Nov 30, 2017 · 1 comment
Closed

fix(modal): ModalDirective: config.animated = false is ignored #3137

flensrocker opened this issue Nov 30, 2017 · 1 comment

Comments

@flensrocker
Copy link
Contributor

Bug description:

When using the modal directive with [config]="{ animated: false }", the modal is fade in/out.

Plunker that reproduces the issue:

Plunkr: https://plnkr.co/edit/cSQd7spPYZFbMNI7y1cm?p=preview

Versions of ngx-bootstrap, Angular, and Bootstrap:

ngx-bootstrap: 2.0.0-beta.9

Angular: 5.0.2

Bootstrap: 3.3.7

@flensrocker
Copy link
Contributor Author

flensrocker commented Dec 1, 2017

Quick & dirty patch:

diff --git a/src/modal/modal.directive.ts b/src/modal/modal.directive.ts
index b50cfa21..83dde295 100644
--- a/src/modal/modal.directive.ts
+++ b/src/modal/modal.directive.ts
@@ -32,6 +32,7 @@ export class ModalDirective implements OnDestroy, OnInit {
   @Input()
   set config(conf: ModalOptions) {
     this._config = this.getConfig(conf);
+    this.isAnimated = this._config.animated;
   }

   get config(): ModalOptions {

or maybe replace this.isAnimated with this._config.animated:

diff --git a/src/modal/modal.directive.ts b/src/modal/modal.directive.ts
index b50cfa21..7cbb3050 100644
--- a/src/modal/modal.directive.ts
+++ b/src/modal/modal.directive.ts
@@ -57,8 +57,6 @@ export class ModalDirective implements OnDestroy, OnInit {
   @Output()
   onHidden: EventEmitter<ModalDirective> = new EventEmitter<ModalDirective>();

-  // seems like an Options
-  isAnimated = true;
   /** This field contains last dismiss reason.
    * Possible values: `backdrop-click`, `esc` and `null`
    * (if modal was closed by direct call of `.hide()`).
@@ -194,7 +192,7 @@ export class ModalDirective implements OnDestroy, OnInit {
     }
     // this._addClassIn = false;

-    if (this.isAnimated) {
+    if (this._config.animated) {
       this.timerHideModal = setTimeout(
         () => this.hideModal(),
         TRANSITION_DURATION
@@ -241,7 +239,7 @@ export class ModalDirective implements OnDestroy, OnInit {
       0
     );

-    if (this.isAnimated) {
+    if (this._config.animated) {
       Utils.reflow(this._element.nativeElement);
     }

@@ -258,7 +256,7 @@ export class ModalDirective implements OnDestroy, OnInit {
       this.onShown.emit(this);
     };

-    if (this.isAnimated) {
+    if (this._config.animated) {
       setTimeout(transitionComplete, TRANSITION_DURATION);
     } else {
       transitionComplete();
@@ -303,14 +301,14 @@ export class ModalDirective implements OnDestroy, OnInit {
       this._backdrop
         .attach(ModalBackdropComponent)
         .to('body')
-        .show({isAnimated: this.isAnimated});
+        .show({isAnimated: this._config.animated});
       this.backdrop = this._backdrop._componentRef;

       if (!callback) {
         return;
       }

-      if (!this.isAnimated) {
+      if (!this._config.animated) {
         callback();

         return;

@valorkin valorkin changed the title ModalDirective: config.animated = false is ignored fix(modal): ModalDirective: config.animated = false is ignored Dec 1, 2017
@ghost ghost removed the ready for tests label Dec 4, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants