Ext 开发小组则提供了 Fx 类集中处理了大部分常用的 js 动画特效,减少了我们自己手写代码的复杂度。

面我给出一个简单的实例代码,其中囊括了大部分的 Ext 动画效果:

(注意导入js和css文件的目录,图片自己设置)

CartoonExt.js

var WIDTH = 300; // 图片宽

var HEIGHT = 300; // 图片高

function reset() {

    // 以 Ext 获得指定元素,并指定此元素左边距、上方边距、右边距、下方边距

    Ext. get ( 'picture' ).highlight().setBounds(10, 10, WIDTH + 10, HEIGHT + 10);

}

function enlarge() {

    reset();

    // 在指定时间内移动到指定位置

    Ext. get ( 'picture' ).setBounds(150, 80, WIDTH + 50, WIDTH + 80, { // 指定的位置

       duration : 1.0 //duration:Number  事件完成时间(以秒为单位)

    });

}

function play() {

    Ext. get ( 'picture' ).highlight().fadeOut().fadeIn().pause(2).switchOff().puff();

    // IE 下不支持 switchOn() 方法,这是一个 Ext 的 bug

}

function fadeout() {

    // 设定最后不透明度为 0.0( 完全透明 ), 持续时间为 1.0 ,方式为 easeNone

    Ext. get ( 'picture' ).setOpacity (0.0, {

       duration : 1.0,

       easing : 'easeNone' //easing:String  行为方法 默认值是 :easeOut

    });

}

function fadein() {

    Ext. get ( 'picture' ).setOpacity (1.0, {

       duration : 1.0,

       easing : 'easeNone'

    });

}

function execution() {

    reset();

    var easingMethod = document.getElementByIdx_x( 'easing' ).value;

    Ext. get ( 'picture' ).setLocation(150, 150, {

       duration : 1.0,

       easing : easingMethod

    });

}

----------------------------------------------------------------------------------------------------------------

CartoonExt.html

<! DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN""http://www.w3.org/TR/html4/loose.dtd" >

< html >

    < head >

       < meta http-equiv = "Content-Type" content = "text/html; charset=utf-8" >

       < title > CartoonExt </ title >

       < script type = "text/javascript" src = "../js/ext-base.js" ></ script >

       < script type = "text/javascript" src = "../js/ext-all.js" ></ script >

       < script type = "text/javascript" src = "../js/CartoonExt.js" ></ script >

    </ head >

    < body >

       < div style = "width: 300px; height: 300px;" >

           <!-- 被移动的元素 -->

           < img id = "picture" src = "../images/test_1.jpg" >

       </ div >

       < div style = "text-align: center;" >

           < input type = "button" value = " 刷新 " onclick = "reset()" >

           < input type = "button" value = " 逐渐放大 " onclick = "enlarge();" >

           < input type = "button" value = " 淡出 " onclick = "fadeout();" >

           < input type = "button" value = " 淡入 " onclick = "fadein();" >

           < input type = "button" value = " 连续动画 " onclick = "play();" >

           < BR >

           < BR >

           效果列表

           < select id = "easing" >

              < option value = "easeNone" > easeNone </ option >

              < option value = "easeIn" > easeIn </ option >

              < option value = "easeOut" > easeOut </ option >

              < option value = "easeBoth" > easeBoth </ option >

              < option value = "easeInStrong" > easeInStrong </ option >

              < option value = "easeOutStrong" > easeOutStrong </ option >

              < option value = "easeBothStrong" > easeBothStrong </ option >

              < option value = "elasticIn" > elasticIn </ option >

              < option value = "elasticOut" > elasticOut </ option >

              < option value = "elasticBoth" > elasticBoth </ option >

              < option value = "backIn" > backIn </ option >

              < option value = "backOut" > backOut </ option >

              < option value = "backBoth" > backBoth </ option >

              < option value = "bounceIn" > bounceIn </ option >

              < option value = "bounceOut" > bounceOut </ option >

              < option value = "bounceBoth" > bounceBoth </ option >

           </ select >

           < input type = "button" value = " 执行 " onclick = "execution();" >

       </ div >

    </ body >

</ html > 

----------------------------------------------------------------------------------------------------------------

部分参数如下: 

fadeIn ( [Object options] ) : Ext.Element 渐显 options 参数有以下属性
callback:Function 完成后的回叫方法
scope:Object 目标
easing:String 行为方法 默认值是:easeOut, 可选值如下 字段值 说明 easeNone 匀速 easeIn 开始慢且加速 easeOut 开始快且减速 easeBoth: 开始慢且减速 easeInStrong 开始慢且加速,t 的四次方 easeOutStrong 开始快且减速,t 的四次方 easeBothStrong 开始慢且减速,t 的四次方 afterCls:String 事件完成后元素的样式
duration:Number 事件完成时间(以秒为单位)
remove:Boolean 事件完成后元素销毁?
useDisplay:Boolean 隐藏元素是否使用display 或visibility 属性?
afterStyle:String/Object/Function 事件完成后应用样式
block:Boolean 块状化
concurrent:Boolean 顺序还是同时执行
stopFx :Boolean 当前效果完成后随合的效果是否将停止和移除 fadeOut( [Object options] ) : Ext.Element 渐隐
fadeOut 和fadeIn 能使用一个特别的endOpacity 属性以指示结束时的透明度
例:el.fadeIn({duration:5,endOpacity:0.7}); frame( [String color], [Number count], [Object options] ) : Ext.Element 边框变亮扩展然后渐隐
例:el.frame("ff0000", 10, { duration: 3 }) ghost( [String anchor], [Object options] ) : Ext.Element 渐渐滑出视图,anchor 定义
tl 左上角( 默认)
t 上居中
tr 右上角
l 左边界的中央
c 居中
r 右边界的中央
bl 左下角
b 下居中
br 右下角
例:
el.ghost('b', {
easing: 'easeOut',
duration: .5
remove: false,
useDisplay: false
}); hasActiveFx() : Boolean 指示元素是否当前有特效正在活动 hasFxBlock() : Boolean 是否有特效阻塞了 highlight( [String color], [Object options] ) : Ext.Element 高亮显示当前元素
例:el.highlight("ffff9c", {
attr: "background-color", //can be any valid CSS property (attribute) that supports a color value
endColor: (current color) or "ffffff",
easing: 'easeIn',
duration: 1
}); pause( Number seconds ) : Ext.Element 暂停 puff( [Object options] ) : Ext.Element 元素渐大并隐没
例:el.puff({
easing: 'easeOut',
duration: .5,
remove: false,
useDisplay: false
}); scale( Number width, Number height, [Object options] ) : Ext.Element 缩放
例:el.scale(
[element's width],
[element's height], {
easing: 'easeOut',
duration: .35
}); sequenceFx() 特效序列 shift( Object options ) : Ext.Element 位移, 并可重置大小, 透明度等
例:
el.shift({
width: [element's width],
height: [element's height],
x: [element's x position],
y: [element's y position],
opacity: [element's opacity],
easing: 'easeOut',
duration: .35
}); slideIn( [String anchor], [Object options] ) : Ext.Element 淡入 slideOut( [String anchor], [Object options] ) : Ext.Element 淡出
例:el.slideIn('t', {
easing: 'easeOut',
duration: .5
}); stopFx() : Ext.Element 停止特效 switchOff( [Object options] ) : Ext.Element 收起并隐没
例:
el.switchOff({
easing: 'easeIn',
duration: .3,
remove: false,
useDisplay: false
});

参考:http://blog.sina.com.cn/s/blog_74684ec501015lhq.html

ExtJS简单的动画效果2(ext js淡入淡出特效)的更多相关文章

  1. ExtJS简单的动画效果(ext js淡入淡出特效)

    1.html页面:Application HTML file - index.html <html> <head> <title>ExtJs fadeIn() an ...

  2. 32.ExtJS简单的动画效果

    转自:http://blog.sina.com.cn/s/blog_74684ec501015lhq.html 说明:这篇文章的大部分内容来源于网上,经过自己实现其效果后,整理如下: 在进行 Java ...

  3. 【从无到有】教你使用animation做简单的动画效果

    今天写写怎么用animation属性做一些简单的动画效果 在CSS选择器中,使用animition动画属性,调用声明好的关键帧 首先声明一个动画(关键帧): @keyframes name{ from ...

  4. 用Direct2D和DWM来做简单的动画效果2

    原文:用Direct2D和DWM来做简单的动画效果2 版权声明:本文为博主原创文章,未经博主允许不得转载. https://blog.csdn.net/sunnyloves/article/detai ...

  5. 用Direct2D和DWM来做简单的动画效果

    原文:用Direct2D和DWM来做简单的动画效果 版权声明:本文为博主原创文章,未经博主允许不得转载. https://blog.csdn.net/sunnyloves/article/detail ...

  6. js 淡入淡出的图片

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  7. js淡入淡出

    示例: js淡入淡出 原理:更改css不透明数值 知识点: css不透明 filter:alpha(opacity:30); opacity:0.3;} 小技巧: 小于临界值,做加速 大于临界值,做减 ...

  8. 基于jquery fly插件实现加入购物车抛物线动画效果,jquery.fly.js

    在购物网站中,加入购物车的功能是必须的功能,有的网站在用户点击加入购物车按钮时,就会出现该商品从点击出以抛物线的动画相似加入购物车,这个功能看起来非常炫,对用户体验也有一定的提高.下面介绍基于jque ...

  9. jquery使用CSS3实现文字动画效果插件Textillate.js

    Textillate是一款基于jquery的使用CSS3实现文字动画的小巧插件.Textillate.js集成了一些很棒的使用CSS3动画效果的 JavaScript 库,您可非常轻轻松地把这些动画效 ...

随机推荐

  1. 栈的链式存储 - API实现

    基本概念 其它概念详情參看前一篇博文:栈的顺序存储 - 设计与实现 - API实现 这里也是运用了链表的链式存储API高速实现了栈的API. 代码: // linkstack.h // 链式存储栈的A ...

  2. UVa 10400 - Game Show Math 游戏中的数学 dfs+判重

    题意:给出一些数字和一个目标数字,要求你在数字间添加+-*/,让表达式能达到目标数字,运算符号的优先级都是一样的. 由于数据量很大,本来想用map<string>判重的,结果还是超时了,然 ...

  3. [Angular 2] 9. Replace ng-modle with #ref & events

    Let's say you want to write a simple data bing app. when you type in a text box, somewhere in the ap ...

  4. Nubia Z5S(高通公司MSM8974) QHSUSB_BULK砖的方法节省模式(随着win7在恢复recovery分区案例)

    Nubia Z5S在某些异常情况或按组合键进入QHSUSB_BULK状态, 这种模式的现象, 猜想windows(实例win7)即使在数据线, 它会出现在计算机n载,甚至会提示要格式化某些分区(这里要 ...

  5. 高级性能调试手段(oprofile+gprofile)+内核追踪手段:LTT

    http://blog.csdn.net/wlsfling/article/details/5876134http://www.lenky.info/archives/2012/03/1371http ...

  6. 【ES6】Set和Map中的NaN

    在JavaScript中,有个有意思的的式子:NaN !== NaN.在Set中的元素的重复检查或者Map键的定位过程中,都是用的类似恒等的检查逻辑.该逻辑和恒等检查的主要区别就是:NaN等于自身.

  7. Android(java)学习笔记212:中文乱码的问题处理(qq登录案例)

    1.我们在之前的笔记中LoginServlet.java中,我们Tomcat服务器回复给客户端的数据是英文的"Login Success","Login Failed&q ...

  8. noip 2003 传染病控制(历史遗留问题2333)

    /*codevs 1091 搜索 几个月之前写的70分 今天又写了一遍 并且找到了错误 */ #include<cstdio> #include<vector> #define ...

  9. 开源的Android开发框架-------PowerFramework使用心得(五)网络请求HTTPRequest

    GET请求示例 //所有参数都使用Bundle,用putString Bundle bundle = new Bundle(); bundle.putString("username&quo ...

  10. javascript google map circle radius_changed ,angularjs google map circle radius_changed

    javascript: var cityCircle = new google.maps.Circle({ strokeColor: '#FF0000', strokeOpacity: 0.8, st ...