jQuery旋轉(zhuǎn)插件—rotate支持(ie/Firefox/SafariOpera/Chrome)
網(wǎng)上發(fā)現(xiàn)一個(gè)很有意思的jQuery旋轉(zhuǎn)插件,支持Internet Explorer 6.0+ 、Firefox 2.0 、Safari 3 、Opera 9 、Google Chrome,高級(jí)瀏覽器下使用Transform,低版本ie使用VML實(shí)現(xiàn)。
調(diào)用和方法:
rotate(angle)
angle參數(shù):[Number] – 默認(rèn)為 0 – 根據(jù)給定的角度旋轉(zhuǎn)圖片
例如:
$("#img").rotate(45);
rotate(parameters)
parameters參數(shù):[Object] 包含旋轉(zhuǎn)參數(shù)的對(duì)象。支持的屬性:
1.angle屬性:[Number] – default 0 – 旋轉(zhuǎn)的角度數(shù),并且立即執(zhí)行
例如:
$("#img").rotate({angle:45});
2.bind屬性:[Object] 對(duì)象,包含綁定到一個(gè)旋轉(zhuǎn)對(duì)象的事件。事件內(nèi)部的$(this)指向旋轉(zhuǎn)對(duì)象-這樣你可以在內(nèi)部鏈?zhǔn)秸{(diào)用- $(this).rotate(…)。例如 (click on arrow):
$("#img").rotate({bind:{
click: function(){
$(this).rotate({
angle: 0,
animateTo:180
})
}
}
});
3.animateTo屬性:[Number] – default 0 – 從當(dāng)前角度值動(dòng)畫旋轉(zhuǎn)到給定的角度值 (或給定的角度參數(shù))例如: 結(jié)合上面的例子,請(qǐng)參閱使用。
4.duration屬性:[Number] – 指定使用animateTo的動(dòng)畫執(zhí)行持續(xù)時(shí)間例如 (click on arrow):
$("#img").rotate({bind:{
click: function(){
$(this).rotate({
duration:6000,
angle: 0,
animateTo:100
})
}
}
});
5.step屬性:[Function] – 每個(gè)動(dòng)畫步驟中執(zhí)行的回調(diào)函數(shù),當(dāng)前角度值作為該函數(shù)的第一個(gè)參數(shù)
6.easing屬性:[Function] – 默認(rèn) (see below) – Easing function used to make animation look more natural. It takes five parameters (x,t,b,c,d) to support easing from http://gsgd.co.uk/sandbox/jquery/easing/ (for more details please see documentation at their website). Remember to include easing plugin before using it in jQueryRotate!Default function:
function (x, t, b, c, d) { return -c * ((t=t/d-1)*t*t*t - 1) + b; }
Where:t: current time,
b: begInnIng value,
c: change In value,
d: duration,
x: unused
No easing (linear easing):
function(x, t, b, c, d) { return (t/d)*c ; }
Example (click on arrow):
$("#img").rotate({bind:{
click: function(){
$(this).rotate({
angle: 0,
animateTo:180,
easing: $.easing.easeInOutElastic
})
}
}
});
7.callback屬性:[Function] 動(dòng)畫完成時(shí)執(zhí)行的回調(diào)函數(shù)例如 (click on arrow):
$("#img").rotate({bind:{
click: function(){
$(this).rotate({
angle: 0,
animateTo:180,
callback: function(){ alert(1) }
})
}
}
});
getRotateAngle
這個(gè)函數(shù)只是簡(jiǎn)單地返回旋轉(zhuǎn)對(duì)象當(dāng)前的角度。
例如:
$("#img").rotate({
angle: 45,
bind: {
click : function(){
alert($(this).getRotateAngle());
}
}
});
stopRotate
這個(gè)函數(shù)只是簡(jiǎn)單地停止正在進(jìn)行的旋轉(zhuǎn)動(dòng)畫。
例如:
$("#img").rotate({
bind: {
click: function(){
$("#img").rotate({
angle: 0,
animateTo: 180,
duration: 6000
});
setTimeout(function(){
$("#img").stopRotate();
}, 1000);
}
}
});
用這個(gè)可以實(shí)現(xiàn)很多關(guān)于旋轉(zhuǎn)的網(wǎng)頁(yè)特效,我用這個(gè)做了個(gè)抽獎(jiǎng)大轉(zhuǎn)盤,效果不錯(cuò),就是沒(méi)flash順暢,基本能跑哈哈。
jqueryrotate項(xiàng)目地址:http://code.google.com/p/jqueryrotate/
代碼示例:http://code.google.com/p/jqueryrotate/wiki/Examples
一步一步往上爬
相關(guān)文章
jQuery插件Validation快速完成表單驗(yàn)證的方式
這篇文章主要為大家詳細(xì)介紹了jQuery插件Validation快速完成表單驗(yàn)證的方式,感興趣的小伙伴們可以參考一下2016-07-07
ligerUI的ligerDialog關(guān)閉刷新的方法
今天小編就為大家分享一篇ligerUI的ligerDialog關(guān)閉刷新的方法,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2019-09-09
jQuery實(shí)現(xiàn)下拉菜單動(dòng)態(tài)添加數(shù)據(jù)點(diǎn)擊滑出收起其他功能
這篇文章主要介紹了jQuery實(shí)現(xiàn)下拉菜單動(dòng)態(tài)添加數(shù)據(jù)點(diǎn)擊滑出收起其他功能,本文給大家介紹的非常詳細(xì),需要的朋友可以參考下2018-06-06
Jquery Easyui日歷組件Calender使用詳解(23)
這篇文章主要為大家詳細(xì)介紹了Jquery Easyui日歷組件Calender的使用方法,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2016-12-12
jQuery控制li上下循環(huán)滾動(dòng)插件用法實(shí)例(附demo源碼下載)
這篇文章主要介紹了jQuery控制li上下循環(huán)滾動(dòng)插件用法,結(jié)合實(shí)例形式分析了jQuery循環(huán)滾動(dòng)插件的實(shí)現(xiàn)技巧與使用方法,并附帶demo源碼供讀者下載參考,需要的朋友可以參考下2016-05-05
jquery在ie7下選擇器的問(wèn)題導(dǎo)致append失效的解決方法
這篇文章主要介紹了jquery在ie7下選擇器的問(wèn)題導(dǎo)致append失效的解決方法2016-01-01
使用jquery讀取html5 localstorage的值的方法
在HTML 5中,localstorage是個(gè)不錯(cuò)的東西,在支持localstorage的瀏覽器中, 能持久化用戶表單的輸入,即使關(guān)掉瀏覽器,下次重新打開瀏覽器訪問(wèn),也能讀出其值,很不錯(cuò)的一個(gè)東西,接下來(lái)實(shí)例介紹,需要的朋友可以參考下2013-01-01
jQuery插件Tooltipster實(shí)現(xiàn)漂亮的工具提示
Tooltipster是一個(gè)jQuery插件用于快速創(chuàng)建HTML5校驗(yàn)并且靈活的Tooltips。它可以通過(guò)CSS來(lái)改變外觀,箭頭的位置之后,鼠標(biāo),延遲/期間的外觀都可以被定義。2015-04-04

