31

Is it possible to turn off the animation for the modal directive in angular-ui? http://angular-ui.github.io/bootstrap/

Can't find any in the options. Should I modify the source? Or is there any best practice when you want to customize?

AlfaTeK
  • 7,487
  • 14
  • 49
  • 90
Joe
  • 4,274
  • 32
  • 95
  • 175

5 Answers5

35

Currently, the bootstrap classes are embedded in the directive and need to be overridden. If you want to prevent that vertical 'drift' into position of the modal window, place the following 2 classes in your css :

.modal.fade {
  opacity: 1;
}

.modal.fade .modal-dialog, .modal.in .modal-dialog {
  -webkit-transform: translate(0, 0);
  -ms-transform: translate(0, 0);
  transform: translate(0, 0);
}

What you would be accomplishing here is the negation of the existing translations. Not ideal, however will do the trick.

beauXjames
  • 8,222
  • 3
  • 49
  • 66
19

animation (Type: boolean, Default: true) - Set to false to disable animations on new modal/backdrop. Does not toggle animations for modals/backdrops that are already displayed.

var modalInstance = $uibModal.open({
  animation: false
Mo.
  • 26,306
  • 36
  • 159
  • 225
7

An easy way to turn off the animation is to add !important styles to the modal.

For all Modals

You can do that globally for all the modals with this CSS class (put it anywhere in your css):

.modal {
   top: 25% !important;
   opacity: 1 !important;
}

It will eliminate the "slide from top" animation and also the opacity animation. Personally I prefer to only eliminate the first and use only top: 25% !important;

You can also eliminate the backdrop animation globally using this class (put it anywhere in your css):

.modal-backdrop {
   opacity: 0.8 !important;
}

For a Specific modal

You can eliminate the animations of a specific modal using the windowClass param.

.no-animation-modal {
  top: 25% !important;
  opacity: 1 !important;
}

Using windowClass:

var modalInstance = $modal.open({
  templateUrl: 'myModalContent.html',
  controller: ModalInstanceCtrl,
  windowClass: 'no-animation-modal'
});
guya
  • 5,067
  • 1
  • 35
  • 28
0

Don't have a full answer, but I'm having a similar issue and thought I'd chime in. I know that this used to be possible in angular-ui/bootstrap 0.5. There might be breaking changes in 0.6, and I'm trying to find an answer, but the documentation is pretty lacking.

Here is the example given in 0.5. Notice you can set options like backdropFade but I can't find the equivalent in 0.6. Might have something to do with removing $dialogProvider.

Kenjamin
  • 53
  • 8
  • Kenjamin, you should update answer with [https://github.com/angular-ui/bootstrap/issues/1085] showing that it is suggested to override the HTML template in your source to make changes. For instance, I overrode the tpls example template with the same code just removing the fade class. – d456 Nov 19 '13 at 16:16
0

The below is working well for me, whatever the animation: false or animation: true:

<style>
        .modal.fade {
            opacity: 1;
        }

        .modal.fade .modal-dialog, .modal.in .modal-dialog {
            -webkit-transform: translate(0, 0);
            -ms-transform: translate(0, 0);
            transform: translate(0, 0);
        }

        .modal-backdrop {
            opacity: 0.8 !important;
        }

</style>
Raymond Liao
  • 1,799
  • 3
  • 20
  • 32