天天躁日日躁狠狠躁AV麻豆-天天躁人人躁人人躁狂躁-天天澡夜夜澡人人澡-天天影视香色欲综合网-国产成人女人在线视频观看-国产成人女人视频在线观看

JS Tween 顏色漸變

有31中緩動(dòng)算法,實(shí)現(xiàn)了顏色的自動(dòng)轉(zhuǎn)換(#f00 #ff0000 rgb(255,0,0)格式到顏色運(yùn)算格式,最后返回#ff0000格式)、px單位的自動(dòng)轉(zhuǎn)換。
調(diào)用接口:
/**
* 對(duì)外接口
* Tween的示例
* @param startProps 開(kāi)始屬性,單個(gè)屬性或者數(shù)組
* @param endProps 結(jié)束屬性,單個(gè)屬性或者數(shù)組
* @param timeSeconds 運(yùn)動(dòng)消耗時(shí)間,單位秒
* @param animType 動(dòng)作類(lèi)型,字符串型,內(nèi)部自己轉(zhuǎn)換算子
* @param delay 延遲時(shí)間,多長(zhǎng)時(shí)間后開(kāi)始運(yùn)動(dòng),單位秒
*/
window.rtween = function(startProps, endProps, timeSeconds, animType, delay)
{
var tw = new Tween();
tw.start(startProps, endProps, timeSeconds, animType, delay);
return tw;
}
示例如下:
http://img.jb51.NET/online/Tween.htm

[Ctrl+A 全選 注:如需引入外部Js需刷新才能執(zhí)行]
選擇列表里面的緩動(dòng)算法,點(diǎn)前面的按鈕,就會(huì)以想對(duì)的緩動(dòng)算法運(yùn)動(dòng)

源代碼: http://img.jb51.NET/jslib/jquery/rtween.js
核心代碼:
function Tween()
{
this._frame=20;
//
this._animType = linear;
this._delay = 0;
//
this.run = function(){}
this.complete = function(){}
}
//
Tween.prototype.getValue = function(prop)
{
this._valueType = ”;
if(prop.constructor == Array) return prop;
//
if(typeof(prop) == 'string')
{
if(isColor(prop))
{
this._valueType = ‘color';
return c2a(prop);
}
if(prop.split('px').length>1)
{
this._valueType = ‘px';
return [prop.split('px')[0]];
}
}
return [prop];
}
Tween.prototype.setValue = function(prop)
{
if(this._valueType == ‘color')return a2c(prop);
if(this._valueType == ‘px')return prop[0]+'px';
return prop;
}
Tween.prototype.start = function(startProps, endProps, timeSeconds, animType, delay)
{
if(animType != undefined)this._animType = this.animTypes[animType];
if(delay != undefined)this._delay = delay;
//
this._timeSeconds = timeSeconds;
this._startTimer = new Date().getTime() + this._delay * 1000;
//
this._endProps = this.getValue(endProps);
this._startProps = this.getValue(startProps);
this._currentProps = [];
//
var $this = this;
clearInterval(this._runID);
this._runID = setInterval(
function(){$this._run();}
,this._frame);
}
Tween.prototype.stop = function(state)
{
for(var i in this._startProps)
{
if(Number(state)>0)
this._currentProps[i] = this._endProps[i];
else if(Number(state)<0)
this._currentProps[i] = this._startProps[i];
}
this.callListener();
this.complete();
//
clearInterval(this._runID);
}
Tween.prototype.callListener = function()
{
this.run(this.setValue(this._currentProps));
}
Tween.prototype._run = function()
{
if ( new Date().getTime()- this._startTimer< 0) return;
var isEnd = false;
//
for(var i in this._startProps)
{
this._currentProps[i] = this._animType( new Date().getTime()-this._startTimer,Number(this._startProps[i]),Number(this._endProps[i])-Number(this._startProps[i]),this._timeSeconds * 1000);
//
if(this._startTimer + (this._timeSeconds * 1000) <= new Date().getTime())
{
this._currentProps[i] = this._endProps[i];
isEnd = true;
}
}
//
if(isEnd)this.stop();
else this.callListener();
}

JavaScript技術(shù)JS Tween 顏色漸變,轉(zhuǎn)載需保留來(lái)源!

鄭重聲明:本文版權(quán)歸原作者所有,轉(zhuǎn)載文章僅為傳播更多信息之目的,如作者信息標(biāo)記有誤,請(qǐng)第一時(shí)間聯(lián)系我們修改或刪除,多謝。

主站蜘蛛池模板: 亚洲高清在线mv | 9477小游戏| 国产成人亚洲精品老王 | 国产乱码卡二卡三卡4W | 亚洲伊人久久一次 | 精品午夜久久福利大片免费 | 午夜精品久久久久久久爽牛战 | 富婆夜店找黑人猛男BD在线 | 一个人免费观看完整视频日本 | 秋霞伦理电影在2017韩国在线伦 | 精品午夜中文字幕熟女人妻在线 | 中文国产在线观看 | 肉多荤文高h羞耻校园 | 我们日本在线观看免费动漫下载 | 日韩一区二区三区视频在线观看 | 九九免费的视频 | 艺术片 快播 | 欧美不卡一区二区三区 | 美女扒开尿孔 | 久久99热狠狠色AV蜜臀 | 公和熄洗澡三级中文字幕 | 被窝国产理论一二三影院 | 色婷婷亚洲精品天天综合影院 | 成人影片下载网站 | 少妇大荫蒂毛多毛大 | 久久视频在线视频观看天天看视频 | 亚洲日本一区二区三区在线不卡 | 9久久免费国产精品特黄 | www免费看.男人的天堂 | 久久er国产精品免费观看2 | 国产人妻人伦精品59HHH | 5g天天奭视频 | 试看做受120秒免费午夜剧场 | 影音先锋av电影 | 高清国语自产拍免费 | 性夜a爽黄爽| 999精品影视在线观看 | 99re8久久热在线视频 | 久久久久亚洲日日精品 | 亚洲欧美精品无码大片在线观看 | 国产美女又黄又爽又色视频网站 |