1

I do an app with Angularjs and ui.Bootstrap

I use a $routeProvider so I have an <ng-view></ng-view> in my main page,

with animate.css, I want to animate enter and leave of my view, but bootstrap doesn't had both class ( .myclass-enter and .myclass-leave ) I don't know why?

1
  • You need to include angular-version/angular-animate.js and list ngAnimate module as dependency in your module. Those classes are added by ngAnimate module. Commented Jul 30, 2015 at 19:59

2 Answers 2

3

This is not responsibility of Bootstrap to animate ng-view element. But you can easily achieve this with ngAnimate module (remember to inject it into your main app module). All you need to do is to implement couple of classes.

For example to make view slide you can write this classess:

<div ng-view class="slide"></div>

and CSS:

.slide {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
}
.slide.ng-enter,
.slide.ng-leave {
    transition: all 1s ease;
}
.slide.ng-enter {
    left: 100%;
}
.slide.ng-enter-active,
.slide.ng-leave {
    left: 0;
}
.slide.ng-leave-active {
    left: -100%;
}

Here is some examples I put together of this approach.

Sign up to request clarification or add additional context in comments.

3 Comments

I think question may be related to ng-animate which adds those classes. OP says he is already using animate.css.
Yes, of course ngAnimate is required, however you still need to implement ng-enter/leave classes, with animate.css animations or simple transitions.
Sure, i just commented because you seemed to have missed it in your answer initially. I was focusing on with animate.css, I want to animate enter and leave of my view, but bootstrap doesn't had both class assuming that OP has got some sample of animation classes with rules
1

thinx I think I forget vendor prefix on my css class, so it works with animate.css now

.slide.ng-enter,
.slide.ng-leave {
}
.slide.ng-enter {
    animation-delay: 1s;
}
.slide.ng-enter-active {
    -webkit-animation-name: bounceIn;
            animation-name: bounceIn;
}
.slide.ng-leave {
}
.slide.ng-leave-active {
    -webkit-animation-name: hinge;
            animation-name: hinge;
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.