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 的动画

如果是在使用指令的时候使用templateUrl 也可能会出现这样的情形,因为templateUrl会发http请求,是异步操作,页面会先渲染,等到template加载回来,page load 算已经结束了。

要避免这样的情况可以为先添加ng-hide在class上,这样它会直接hide起来了 <div class='ng-hide'></div>.

Animate 动画的更多相关文章

  1. jquery animate 动画效果使用解析

    animate的意思是:使有生气:驱动:使栩栩如生地动作:赋予…以生命作为形容词:有生命的:活的:有生气的:生气勃勃的 先看动画效果:http://keleyi.com/keleyi/phtml/jq ...

  2. 解决animate动画连续播放bug

    在animate动画中,如果几个div之间频繁切换,会导致鼠标移开后,动画仍在继续,解决方法有两个 一个,判断当前是否在运行动画: if(!$(".block").is(" ...

  3. jQuery中animate动画第二次点击事件没反应

    jQuery中animate动画第二次点击事件没反应 用animate做点击翻页动画时发现第二次点击事件动画没反应,而第一次点击有动画效果,代码如下: 复制代码 代码如下: $(".page ...

  4. jquery IE6 下animate 动画的opacity无效

    jquery IE6 下animate 动画的opacity无效,其实是有效的,因为IETester的一个小BUG 原生IE6 没问题...呵呵~~

  5. svg的animate动画动态加载删除遇到删除animate后再次加载的animate动画没有效果问题

    svg上有多个圆圈,当选中特定圆圈后给其加上animate动画效果,并把其他圆圈的animate效果去除. 第一次选择一个点实现动画效果完全达到效果,因为是第一次所以不需要把其他圆圈的animate子 ...

  6. jquery的animate({})动画整理

    在网页制作的过程中少不了用到各种动画,形式多种多样,flash,css,js,canvas,等等都能实现,对于其优劣和效果只能说各有千秋. 什么是动画效果,其实网页中的渐变效果就是一种很基础的动画,动 ...

  7. jQuery animate动画 stop()方法详解~

    一.动画格式: 格式一:jQueryObject.animate( cssProperties, options ) 格式二:$('#id').animate( styles[, duration ] ...

  8. jquery animate 动画效果使用说明

    animate( params, [duration], [easing], [callback] ) 用于创建自定义动画的函数. 这个函数的关键在于指定动画形式及结果样式属性对象.这个对象中每个属性 ...

  9. .animate动画

    .animate(params, [duration], [easing], [callback]) params: 结果样式属性 duration: 动画时长 也可以用 slow normal fa ...

随机推荐

  1. Boost编程之获取可执行文件的当前路径

    #include <boost/filesystem/path.hpp> #include <boost/filesystem/operations.hpp> std::str ...

  2. C#中判断字符串是否中文的方法

    public bool IsChinaString(string CString) { bool BoolValue = false; ; i < CString.Length; i++) { ...

  3. How to Read an Engineering Research Paper

    How to Read an Engineering Research Paper William G. Griswold Department of Computer Science & E ...

  4. 【转】ASP.NET MVC框架下使用MVVM模式-KnockOutJS+JQ模板例子

    KnockOutJS学习系列----(一) 好几个月没去写博客了,最近也是因为项目紧张,不过这个不是借口,J. 很多时候可能是因为事情一多,然后没法静下来心来去写点东西,学点东西. 也很抱歉,突然看到 ...

  5. 关于使用mybatis插件自动生成代码

    1.安装 mybatis 插件: 在 eclipse 中 点击 help-->Install New Software...--> Add --> local  选择插件中eclip ...

  6. Linux菜鸟学习笔记--Linux系统结构

      什么是Linux? Linux是一种自由和开放源码的类Unix操作系统,存在着许多不同的Linux版本,但它们都使用了Linux内核.严格来讲,Linux这个词本身只表示Linux内核,但实际上人 ...

  7. iOS 音频开发经验汇总

    一.音乐播放类概念 iOS 下能支持歌曲和声音播放的的类有几个: SystemSound AVFoundtion库中的AVAudioPlayer #重要 MediMPMusicPlayerContro ...

  8. C++中虚函数的作用是什么?它应该怎么用呢?(转)

    虚函数联系到多态,多态联系到继承.所以本文中都是在继承层次上做文章.没了继承,什么都没得谈. 下面是对C++的虚函数这玩意儿的理解. 一, 什么是虚函数(如果不知道虚函数为何物,但有急切的想知道,那你 ...

  9. C语言函数指针(转载)

    二.通常的函数调用 一个通常的函数调用的例子:/* 自行包含头文件 */void MyFun(int x); /* 此处的声明也可写成:void MyFun(int) */int main(int a ...

  10. linux内存机制

    ~# free -m         total used  free shared buffers cachedMem: 16086 8579 7507    0      152      800 ...