發(fā)布一個(gè)基于javascript的動(dòng)畫類 Fx.js
更新時(shí)間:2010年11月05日 23:11:32 作者:
支持大部分CSS3屬性的動(dòng)畫(可能要指定詳細(xì)的屬性值)。
復(fù)制代碼 代碼如下:
var example = new Fx(element,//元素
{
form:{
//動(dòng)畫前的樣式
//color:"#00f",
},
to:{
//目標(biāo)樣式
color:"#00f",
"background-color":"#5f5",
opacity:0.9,
},
//線性方法
transition:Transition.elasticInOut,
//動(dòng)畫時(shí)間
duration:5000,
//動(dòng)畫幀值
fps:50,
onAnim:function(s){
//動(dòng)畫過程中
},
onStart:function(){
//動(dòng)畫開始時(shí)
},
onPause:function(){
//動(dòng)畫暫停時(shí)
},
onResume:function(){
//動(dòng)畫恢復(fù)時(shí)
},
onStop:function(){
//動(dòng)畫停止時(shí)
}
}
);
//開始動(dòng)畫
example.start();
//停止動(dòng)畫
example.stop();
//停止動(dòng)畫并恢復(fù)到原始樣式
example.stop(1);
//暫停動(dòng)畫
example.pause();
//恢復(fù)動(dòng)畫
example.resume();
完整演示代碼:
復(fù)制代碼 代碼如下:
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Fx動(dòng)畫類 支持CSS3</title>
<style type="text/css">
*{ margin:0; padding:0; font-size:12px;}
#anim{ border-bottom:3pt solid #006;!important}
button{ width:70px; height:30px; font-size:16px; text-align:center;}
</style>
<script src="../../scripts/Fx.js" type="text/javascript"></script>
<script type="text/javascript">
/* Demo */
var fx,showlog = false;
window.onload = function(){
var anim = document.getElementById("anim");
var log = document.getElementById("log");
fx = new Fx(anim,
{
to:{
position:"absolute",
left:"180px",
top:"180px",
color:"hsla(270, 50%, 50%, 0.8)",
"background-color":"#5f5",
//"background-color":"rgba(0,0,255,0.6)",//"rgb(0,255,128)",//
opacity:0.9,
"font-size":"76px",
"border-top-left-radius":"150px",
"border-top-right-radius":"150px",
"border-bottom-left-radius":"150px",
"border-bottom-right-radius":"150px",
"-moz-border-radius-topleft":"150px",
"-moz-border-radius-topright":"150px",
"-moz-border-radius-bottomright":"150px",
"-moz-border-radius-bottomleft":"150px",
"text-shadow":"#000 9px 6px 2px ",
"-webkit-box-shadow":"#ff0 30px 20px 8px 0px",
"-moz-box-shadow":"#ff0 30px 20px 8px 0px",
width:"300px",
height:"300px",
"line-height":"300px"
},
transition:Transition.elasticIn,//bounceIn
duration:5000,
onAnim:function(s){
var str="";
if(showlog){
str+= '<h1 style="color:red;font-size:16px;">runStyle:</h1>';
for(var k in s){
str+=k+":"+s[k]+"<br />";
}
str+= "laveTime:"+this.laveTime+"<br />";
}
log.innerHTML = str;
},
onStop:function(){
//alert("Stop");
}
}
);
};
</script>
</head>
<body>
<div id="anim" style="
position:absolute;
left:70px;
top:70px;
width:150px;
height:150px;
color:hsla(10, 70%, 70%, 0.8);
border:1px solid #666;
background-color:#ccf;
overflow:hidden;
text-shadow:0px 0px 0px #000;
font-size:26px;
-webkit-box-shadow:0px 0px 0px #000;
-moz-box-shadow:0px 0px 0px #000;
-moz-border-radius:0px;
text-align:center;
line-height:150px;" >
A</div>
<button onClick="fx.start();">start()</button>
<button onClick="fx.pause();">pause()</button>
<button onClick="fx.resume();">resume()</button>
<button onClick="fx.stop(0);">stop(0)</button>
<button onClick="fx.stop(1);">stop(1)</button>
<label for="showlog">顯示數(shù)據(jù):</label>
<input type="checkbox" id="showlog" onClick="showlog = this.checked;" />
<br />
<div id="log"></div>
</body>
</html>
打包下載
相關(guān)文章
Javascript實(shí)用方法之json合并的場景分析
這篇文章主要介紹了Javascript實(shí)用方法之json合并,jQuery 的“extend()”方法有兩個(gè)原型:合并的方法,分別是淺合并和深度合并,本文通過代碼給大家介紹的非常詳細(xì),需要的朋友可以參考下2022-09-09JavaScript之map reduce_動(dòng)力節(jié)點(diǎn)Java學(xué)院整理
這篇文章主要為大家詳細(xì)介紹了JavaScript之map reduce的相關(guān)資料,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2017-06-06layui radio點(diǎn)擊事件實(shí)現(xiàn)input顯示和隱藏的例子
今天小編就為大家分享一篇layui radio點(diǎn)擊事件實(shí)現(xiàn)input顯示和隱藏的例子,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧2019-09-09js 字?jǐn)?shù)統(tǒng)計(jì),區(qū)分英漢
hta實(shí)現(xiàn)的字?jǐn)?shù)統(tǒng)計(jì)效果代碼,中文算兩個(gè),英文算一個(gè)2008-02-02setTimeout時(shí)間設(shè)置為0詳細(xì)解析
setTimeout( ) 是屬于 window 的 method, 但我們都是略去 window 這頂層容器名稱, 這是用來設(shè)定一個(gè)時(shí)間, 時(shí)間到了, 就會(huì)執(zhí)行一個(gè)指定的 method,下面這篇文章主要給大家介紹了關(guān)于setTimeout時(shí)間設(shè)置為0的相關(guān)資料,需要的朋友可以參考下。2018-03-03