一区二区久久-一区二区三区www-一区二区三区久久-一区二区三区久久精品-麻豆国产一区二区在线观看-麻豆国产视频

JS Tween 顏色漸變

有31中緩動算法,實(shí)現(xiàn)了顏色的自動轉(zhuǎn)換(#f00 #ff0000 rgb(255,0,0)格式到顏色運(yùn)算格式,最后返回#ff0000格式)、px單位的自動轉(zhuǎn)換。
調(diào)用接口:
/**
* 對外接口
* Tween的示例
* @param startProps 開始屬性,單個屬性或者數(shù)組
* @param endProps 結(jié)束屬性,單個屬性或者數(shù)組
* @param timeSeconds 運(yùn)動消耗時間,單位秒
* @param animType 動作類型,字符串型,內(nèi)部自己轉(zhuǎn)換算子
* @param delay 延遲時間,多長時間后開始運(yùn)動,單位秒
*/
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í)行]
選擇列表里面的緩動算法,點(diǎn)前面的按鈕,就會以想對的緩動算法運(yùn)動

源代碼: 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)載需保留來源!

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

主站蜘蛛池模板: 91视频综合网 | 九九线精品视频 | 毛片黄片免费看 | 波多野结衣一区二区三区高清在线 | 中文字幕一二三四区2021 | 4hu四虎| 四虎影永久在线高清免费 | 天天色天天综合 | 天天做天天摸天天爽天天爱 | 色五夜婷婷 | 在线色视频网站 | 六月婷婷六月天 | 国产精品永久免费视频观看 | 久久亚洲伊人中字综合精品 | 任我鲁任我在线精品视频 | 国产专区自拍 | 91久久国产精品视频 | 亚洲一区二区三区四区在线观看 | 欧美激情在线精品三区 | 亚洲欧美日韩不卡 | 国产一级一级一级成人毛片 | 91久久精品国产免费一区 | 午夜激情一区 | 一区精品麻豆入口 | 久久亚洲精品成人综合 | 一级毛片一片毛 | 天天躁天天弄天天爱 | 亚洲国产婷婷综合在线精品 | 韩国亚洲伊人久久综合影院 | 久久老司机波多野结衣 | 一区二区三区四区视频在线观看 | 国产全黄三级国产全黄三级书 | 天天干2018| 日韩一级特黄 | 精品哟哟哟国产在线观看不卡 | 国产麻豆福利a v在线播放 | 国产女同一区二区在线 | 国产精品视频网址 | 欧美综合一区二区三区 | 在线视频一区二区三区四区 | 久久狠狠第一麻豆婷婷天天 |