KISSY Anim 动画的实现方式-1
KISSY的动画是通过Anim类的方式实现的。一般我们使用动画类都是这样:
Node.one(‘#test2′).animate(‘left: 500px’, 3, Easing.backOut);
在这个时候发生了那些事情呢,一步步跟踪看看:
KISSY的动画是通过Anim类的方式实现的。一般我们使用动画类都是这样:
Node.one(‘#test2′).animate(‘left: 500px’, 3, Easing.backOut);
在这个时候发生了那些事情呢,一步步跟踪看看:
先引用一段
在那些浏览器下会有跨域问题:http://www.36ria.com/3890
postMessage方式对于ie这样顽固的浏览器是无效的,我们采用一个变通的方式window.name来实现ie6、7下面的跨域。 阅读全文
ant是一个build工具,提高干活效率的好工具。
ant需要java运行环境。
在继续往下看之前的前提是你已经有安装好java环境了。
首先:需要下载Ant,解压到一个目录。(http://www.apache.org/dist/ant/binaries)
比如我解压到x:worklibant
准备工作完成。
接下来在你的工作目录创建一个build.bat文件。
SET PATH=X:worklibantbin;%PATH% SET ANT_HOME=X:worklibant ant -version ant pause
完成!,你可以在这个目录下创建你需要的build.xml文件。需要运行的时候双击build.bat。
最后说一下:build.bat是windows下的批处理文件,可以做很多事情(包括ant会的文件删除、创建、修改、合并等等)。
但是这次我们只是简单的利用批处理文件的修改文件查找路径(PATH变量),这样修改的只会在当前的cmd窗口中生效,
当关闭这个窗口之后所有的又回梦了。
这样做的好处是:
1、可以携带我们的ant在其他任意电脑上干活(只要把libant,还有你的项目目录随时携带,当然最好的方式是通过同步工具同步)。
2、还有个没有验证的好处是可以保持电脑的清洁,不太确定环境变量多了会不会影响电脑速度。
如果你看完这个方法之后觉得jdk也是个累赘的话也可以试试这样做。
在KISSY1.2中有16中中缓动函数。
先解释什么叫缓动函数。这个的从物理的角度描述了。
我们都知道自由落体运动,理想情况下,自由落体就是一个速度不断加快的运动。
用函数表示就Y=kX2
所有感觉很舒服的动画总会或多或少的使用各种缓动效果
Robert Penner 博士的缓动函数介绍
codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0"
WIDTH="640" HEIGHT="480" id="easing_demo" ALIGN="">
使用缓动之后的动画会让人感觉很自然.
KISSY中的缓动函数定义在srcanimeasing.js
/**
* Uniform speed between points.
*/
easeNone: function (t) {
return t;
},
/**
* Begins slowly and accelerates towards end. (quadratic)
*/
easeIn: function (t) {
return t * t;
},
/**
* Begins quickly and decelerates towards end. (quadratic)
*/
easeOut: function (t) {
return ( 2 - t) * t;
},
/**
* Begins slowly and decelerates towards end. (quadratic)
*/
easeBoth: function (t) {
return (t *= 2) < 1 ?
.5 * t * t :
.5 * (1 - (--t) * (t - 2));
},
/**
* Begins slowly and accelerates towards end. (quartic)
*/
easeInStrong: function (t) {
return t * t * t * t;
},
/**
* Begins quickly and decelerates towards end. (quartic)
*/
easeOutStrong: function (t) {
return 1 - (--t) * t * t * t;
},
/**
* Begins slowly and decelerates towards end. (quartic)
*/
easeBothStrong: function (t) {
return (t *= 2) < 1 ?
.5 * t * t * t * t :
.5 * (2 - (t -= 2) * t * t * t);
},
/**
* Snap in elastic effect.
*/
elasticIn: function (t) {
var p = .3, s = p / 4;
if (t === 0 || t === 1) return t;
return -(pow(2, 10 * (t -= 1)) * sin((t - s) * (2 * PI) / p));
},
/**
* Snap out elastic effect.
*/
elasticOut: function (t) {
var p = .3, s = p / 4;
if (t === 0 || t === 1) return t;
return pow(2, -10 * t) * sin((t - s) * (2 * PI) / p) + 1;
},
/**
* Snap both elastic effect.
*/
elasticBoth: function (t) {
var p = .45, s = p / 4;
if (t === 0 || (t *= 2) === 2) return t;
if (t < 1) {
return -.5 * (pow(2, 10 * (t -= 1)) *
sin((t - s) * (2 * PI) / p));
}
return pow(2, -10 * (t -= 1)) *
sin((t - s) * (2 * PI) / p) * .5 + 1;
},
/**
* Backtracks slightly, then reverses direction and moves to end.
*/
backIn: function (t) {
if (t === 1) t -= .001;
return t * t * ((BACK_CONST + 1) * t - BACK_CONST);
},
/**
* Overshoots end, then reverses and comes back to end.
*/
backOut: function (t) {
return (t -= 1) * t * ((BACK_CONST + 1) * t + BACK_CONST) + 1;
},
/**
* Backtracks slightly, then reverses direction, overshoots end,
* then reverses and comes back to end.
*/
backBoth: function (t) {
if ((t *= 2 ) < 1) {
return .5 * (t * t * (((BACK_CONST *= (1.525)) + 1) * t - BACK_CONST));
}
return .5 * ((t -= 2) * t * (((BACK_CONST *= (1.525)) + 1) * t + BACK_CONST) + 2);
},
/**
* Bounce off of start.
*/
bounceIn: function (t) {
return 1 - Easing.bounceOut(1 - t);
},
/**
* Bounces off end.
*/
bounceOut: function (t) {
var s = 7.5625, r;
if (t < (1 / 2.75)) {
r = s * t * t;
}
else if (t < (2 / 2.75)) {
r = s * (t -= (1.5 / 2.75)) * t + .75;
}
else if (t < (2.5 / 2.75)) {
r = s * (t -= (2.25 / 2.75)) * t + .9375;
}
else {
r = s * (t -= (2.625 / 2.75)) * t + .984375;
}
return r;
},
/**
* Bounces off start and end.
*/
bounceBoth: function (t) {
if (t < .5) {
return Easing.bounceIn(t * 2) * .5;
}
return Easing.bounceOut(t * 2 - 1) * .5 + .5;
}
基本上KISSY已经把所有我们可能用的到的缓动函数都已经写好了.