码迷,mamicode.com
首页 > 其他好文 > 详细

Animate 动画

时间:2014-08-13 14:52:46      阅读:629      评论:0      收藏:0      [点我收藏+]

标签:os   io   for   ar   cti   时间   ad   ef   

angular 也提供了animate service 

涉及 $animate,$animateProvider

1.2办法后通过 angular-animate.js 还扩展了一些功能 

 

先来说说大致执行过程实现手法。

现代游览器我们通常是用css3的动画取代了jQeury那种动画实现手法。

我们通过给一个element 添加一个 class 来连接 css写好的一系列动画效果 .

angular 通过ng-show等,为class添加一些 class="ng-hide ng-animate ng-remove-hide ng-remove -active" 等

这些class 来配合你写的css 实现动画效果 

比如ng-show的值改变时,angular会为你的element添加一些class,你的css就会渲染一个动画出来了。

angular还未我们做了一件事,就是remove掉这些class , 原理是通过获取element的css取出duration的时间,然后timeout remove class 

 

需要注意的事 : 

angular 明文规定 

disable animations during bootstrap, but once we bootstrapped, wait again
for another digest until enabling animations. The reason why we digest twice
is because all structural animations (enter, leave and move) all perform a
post digest operation before animating. If we only wait for a single digest
to pass then the structural animation would render its animation on page load.
(which is what we‘re trying to avoid when the application first boots up.)

在运行 bootstrapped 的时候是不会触发 animate 的。之后的事件才会!

原因是,比如我们有个fadeIn/Out效果,page load 时我们要hide

那么在bootstrapped digest时, 如果 ng-show=false 同时加上了 fadeOut的 effect 那可能不是我们希望看到的 (我们更希望它直接display node起来), 所以在page load 时,animate 是不运行的 , 之后我们show ,hide 的时候才会运行 fadeIn/Out 的动画

 

Animate 动画,布布扣,bubuko.com

Animate 动画

标签:os   io   for   ar   cti   时间   ad   ef   

原文地址:http://www.cnblogs.com/keatkeat/p/3910017.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!