简体   繁体   English

ng-show / ng-hide中的动画以角度显示

[英]Animation on ng-show/ng-hide in angular

I have a question about animations in angular js. 我对angular js中的动画有疑问。
In my html file I have created a list with a bootstrap list-group inside it like this: 在我的html文件中,我创建了一个带有引导列表组的列表,如下所示:

HTML HTML

<ul class="sidebar-bottom-list">
<li>
    <a href="#/dossier/" class="active" ng-click="showSubmenu = ! showSubmenu"><span class="glyphicon glyphicon-folder-open">&nbsp;</span>Dossiers</a>
    <div class="list-group narrow-list-group no-padding-bottom slider-top-bottom" ng-show="showSubmenu">
        <a href="#" class="list-group-item active">lijst</a>
        <a href="#" class="list-group-item">algemeen</a>
        <a href="#" class="list-group-item">partijen</a>
        <a href="#" class="list-group-item">documenten</a>
        <a href="#" class="list-group-item">notas</a>
        <a href="#" class="list-group-item">royementen</a>
        <a href="#" class="list-group-item">urenregistratie</a>
        <a href="#" class="list-group-item">voortgang</a>
    </div>
</li>

This shows and hides as it should if the showSubmenu statement is met. 如果满足showSubmenu语句,这将显示和隐藏它。 I like to show and hide the div using a transition in which it swipes up and down. 我喜欢使用上下滑动的过渡效果来显示和隐藏div。
I managed to make this in the css file: 我设法做到这一点的CSS文件:

CSS CSS

.list-group-item {
    color: grey !important;
    border: none !important;
    border-radius: 0px !important;
}
.list-group-item:hover {
    color: #000 !important;
    background: #ccc !important;
}
.slider-top-bottom.ng-hide-add.ng-hide-add-active,
.slider-top-bottom.ng-hide-remove.ng-hide-remove-active {
  -webkit-transition: all linear 0.5s;
  transition: all linear 0.5s;
}

Maybe I need some other module for angular, these are the ones I have loaded right now in the main.js: 也许我需要一些其他的角度模块,这些是我现在已经在main.js中加载的模块:

main.js main.js

var app = angular.module("program", ['ngRoute','mobile-angular-ui.core','mobile-angular-ui.components']);



Is there a way to implement these animations, and what would be the most efficient way of doing this? 有没有实现这些动画的方法,最有效的方法是什么?
I would appreciate some explanation with the answer so I can fully understand this problem. 我希望对答案做出一些解释,以便我可以完全理解此问题。

Make sure in your index.html or whatever you are including the ng-animate scripts. 确保在index.html或包含ng-animate脚本的任何内容中。

In main.js you need to add the ng-animate module. 在main.js中,您需要添加ng-animate模块。

main.js main.js

var app = angular.module("program", ['ngRoute','mobile-angular-ui.core','mobile-angular-ui.components', 'ngAnimate']);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM