`
enix2212
  • 浏览: 24842 次
  • 性别: Icon_minigender_1
  • 来自: 北京
最近访客 更多访客>>
社区版块
存档分类
最新评论

Animate Baseclass

阅读更多
以下代码仅供参考,请下载附件代码,应该是文本编辑器过滤掉了某些字符导致不能运行。

<!--<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">-->
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Animate Baseclass</title>
<style type="text/css">
#square { background: #eee; height: 120px; width: 120px; border: 2px solid #CCC; position: absolute; left: 100px; top: 100px; }
</style>
</head>

<body>
<div id="square">Animate</div>
<script type="text/javascript">


function Animate(o,f,g){var h=this,indicator=arguments.callee,origin=null,config=null;if(!(h instanceof indicator))return new indicator(o,f,g);config={O:h.o=o,P:h.property=f,T:h.t=g.t||0,C:h.c=g.c||50,D:h.d=g.d||100,R:h.r=g.r||false};'function'===typeof(g.callback)&&(config.fn=g.callback);if(1!==config['O'].nodeType)return false;undefined===this.Tween&&(indicator.prototype.Tween=function(){return h.Bounce.apply(h,arguments)});indicator.prototype.constructor=indicator;indicator.prototype.Bounce=function(t,b,c,d){if((t/=d)<(1/2.75)){return c*(7.5625*t*t)+b}else if(t<(2/2.75)){return c*(7.5625*(t-=(1.5/2.75))*t+.75)+b}else if(t<(2.5/2.75)){return c*(7.5625*(t-=(2.25/2.75))*t+.9375)+b}else{return c*(7.5625*(t-=(2.625/2.75))*t+.984375)+b}};indicator.prototype.fx=function(t,b,c,d){var a=Math.ceil(h.Tween.apply(h,arguments));if(a>h.c){return false}return(true===config['R']?(-a):(a))+origin};indicator.prototype.play=function(O,P){var t=config['T'],b=0,end=false;origin=parseInt(h.currentStyle(o,f));void function(){var a=h.fx(t,b,config['C'],config['D']);O.style[P]=a+'px';Math.abs(a)<config['C']+origin?(t++,setTimeout(arguments.callee,13)):end=true;(true===end&&undefined!==config['fn'])&&(setTimeout(function(){config['fn'].call(h)},300))}()};indicator.prototype.currentStyle=function(a,b){var c=null;return undefined!==a.currentStyle?a.currentStyle[b]:document.defaultView.getComputedStyle(a,null)[b]};Animate.doFade=function(a,b,c,d){var e=undefined!==window.ActiveXObject,calls=arguments.callee,t=this,step;b+=(c?1:-1)/a,(c?b>1:b<0)&&(b=c?1:0),e===true?t.style.filter='alpha(opacity='+b*100+')':t.style.opacity=b;(c?b<1:b>0)&&setTimeout(function(){calls.call(t,a,b,c,d)},1000/a);(c?b===1:b===0&&'undefined'!==typeof d)&&('function'===typeof d&&d.call(t))};Animate.fadeOut=function(a){Animate.doFade.call(this,a/10,1,false)};Animate.fadeIn=function(a){Animate.doFade.call(this,a/10,0,true)};h.play.call(h,config['O'],config['P'])};
*/		
//demo1 面积由中心变化  
    //Animate(square,'height',{c:square.offsetHeight,d:100});  
    //Animate(square,'width',{c:square.offsetWidth,d:100});  
//demo2 综合运动及无限回调  
    /*new Animate(square,'left',{c:300,d:100,callback:function(){   
        setTimeout(function(){  
            new Animate(square,'width',{c:square.offsetWidth,d:200});  
            new Animate(square,'height',{c:square.offsetHeight,d:200});  
            new Animate(square,'top',{c:square.offsetHeight,r:true,d:200,callback:  
                function(){  
                    try{square.parentNode.removeChild(square)}catch(e){};  
                }  
            });  
            fadeOut.call(square,300) ;  
        },2000);  
    }});*/  
      
      
    /*new Animate(square,'left',{c:300,d:100,callback:function(){   
        setTimeout(function(){  
            new Animate(square,'width',{c:square.offsetWidth,d:200});  
            new Animate(square,'height',{c:square.offsetHeight,d:200,callback:function(){  
                  
                new Animate(square,'top',{c:square.offsetHeight,r:true,d:200,callback:  
                    function(){  
                        //try{square.parentNode.removeChild(square)}catch(e){};  
                        new Animate(square,'top',{c:square.offsetHeight,d:200,callback:function(){  
                            new Animate(square,'top',{c:square.offsetHeight,d:200});  
                        }});  
                    }  
                });  
                      
            }});  
              
            //fadeOut.call(square,300) ;  
        },2000);  
    }});   */
       
//demo3 位置面积变化  
//Animate(square,'top');  
//1  
//Animate(square,'width',{c:square.offsetWidth-100,d:100});  
//2  
//Animate(square,'left',{c:square.offsetHeight,d:100});  
  
//demo4  不规则运动  
//Animate(square,'left',{c:square.offsetWidth-100,d:100});  
//Animate(square,'top',{c:square.offsetHeight,d:140});  
	
	
</script>
</body>
</html>





1.改进了代码
2.修正了宽高变化时,从物体中心扩展。
3.修改构造函数,可以不使用new就能实例化。
4.组合了透明度变化
  • fx.zip (2.4 KB)
  • 下载次数: 2
分享到:
评论
1 楼 percy30856 2011-07-29  
好东西 正在弄这个玩意儿 参考学习了

相关推荐

    Mayavi 参考

    Base class: PipelineBase Class hierarchy Advanced Scripting with Mayavi Design Overview: Mayavi as a visualization framework Scripting the mayavi2 application Using the Mayavi envisage plugins ...

    jquery tab插件

    &lt;link rel="stylesheet" href="https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css"&gt; $( function() { $( "#tabs" ).tabs(); } ); ``` 在这个例子中,我们只需要在HTML中添加相应的结构,并调用`$(...

    jquery-base-learn:jquery基础学习

    4. **动画与效果**: jQuery的`.animate()`函数可创建自定义动画,`.fadeIn()`, `.fadeOut()`, `.slideToggle()`等函数则为常见效果提供了便利。`$.fx.speeds`允许调整动画速度。 5. **Ajax交互**: `$.ajax()`, `$....

    winform之GroupBox控件扩展

    public class CustomGroupBox : GroupBox ``` 这样,`CustomGroupBox`就具备了`GroupBox`的所有基本属性、方法和事件。 2. **添加自定义属性** 为了扩展`GroupBox`的功能,我们可以添加新的属性。例如,我们...

    JQuery 进度条

    &lt;link rel="stylesheet" href="https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css"&gt; ``` 接下来,创建一个HTML元素作为进度条容器: ```html &lt;div id="progressbar"&gt;&lt;/div&gt; ``` 然后使用jQuery代码...

    js jquery

    例如,`$("#id")`选取ID为"id"的元素,`$(".class")`选取所有class为"class"的元素。 2. **链式操作**:jQuery对象的方法返回的是jQuery对象本身,所以可以连续调用多个方法,如`$("div").css("color", "red")....

    jQuery实现字符转gif动画表情插件特效.zip

    2. **选择器**:在jQuery中,可以使用简单的CSS选择器来选取页面上的特定元素,例如`$("#id")`选取ID为"id"的元素,`$(".class")`选取所有class为"class"的元素。这在处理复杂DOM结构时大大提高了效率。 3. **DOM...

    Winform 显示Gif图片的实例代码

    public partial class Form1 : Form { // 初始化控件样式 public Form1() { InitializeComponent(); this.SetStyle(ControlStyles.UserPaint, true); this.SetStyle(ControlStyles.DoubleBuffer, true); this...

    c#自定义漂亮按钮

    例如,可以添加新的方法或事件,如`Animate`方法用于实现动画效果,或者`ClickWithShift`事件处理程序,使得按住Shift键点击按钮时触发不同的操作。 5. **代码示例**: 以下是一个简单的代码片段,展示了如何在`...

    Android重写Gallery

    public class MyGallery extends FrameLayout { // Constants private final int swipe_min_distance = 120; private final int swipe_max_off_path = 250; private final int swipe_threshold_veloicty = 400;...

    jQuery1.10.3_API

    1. **选择器**:jQuery提供了一套强大的CSS选择器,如`$("#id")`用于选取ID为指定值的元素,`$(".class")`用于选取具有特定类名的元素,`$("tag")`用于选取所有指定标签的元素。此外,还有属性选择器、子元素选择器...

    移动端截图下载图片,也可以打印

    2. **图片转换**:生成的canvas可以通过`toDataURL`方法获取其内容的base64编码,该编码可以作为图片URL直接用于设置img标签的src属性,从而显示截图。同时,也可以将其转换为Blob对象,进一步通过FileReader或fetch...

    jquery表单UI美化

    1. **动画效果**:jQuery的动画API(如`.fadeIn()`, `.slideUp()`, `.animate()`等)可以让表单元素有更生动的表现,如错误提示的淡入淡出。 2. **实时反馈**:通过监听用户输入,如`on('input')`,可以即时显示...

    Visual C++ 编程资源大全(英文源码 表单)

    18.zip Color Dialog with Persistent Custom Colors 对话框继承了上一次的颜色风格(12KB)&lt;END&gt;&lt;br&gt;19,19.zip A Base Dialog Class for Modal/Modeless Dialog with Custom Background Color 自定义背景...

    Ext Js权威指南(.zip.001

    4.4.3 所有继承类的基类:ext.base / 151 4.4.4 实现动态加载:ext.loader / 151 4.4.5 管理类的类:ext.classmanager / 159 4.4.6 类创建的总结 / 161 4.5 动态加载的路径设置 / 163 4.6 综合实例:页面...

    VB编程资源大全(英文源码 控制)

    &lt;END&gt;&lt;br&gt;33 , vbo_button_bas.zip This bas contains functions to manipulate Button class objects&lt;END&gt;&lt;br&gt;34 , LPT_Port.zip Read/write to LPT parallel port&lt;END&gt;&lt;br&gt;35 , DancingBaby.zip A ...

Global site tag (gtag.js) - Google Analytics