jQuery旋轉(zhuǎn)插件—rotate支持(ie/Firefox/SafariOpera/Chrome)
網(wǎng)上發(fā)現(xiàn)一個很有意思的jQuery旋轉(zhuǎn)插件,支持Internet Explorer 6.0+ 、Firefox 2.0 、Safari 3 、Opera 9 、Google Chrome,高級瀏覽器下使用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ù)的對象。支持的屬性:
1.angle屬性:[Number] – default 0 – 旋轉(zhuǎn)的角度數(shù),并且立即執(zhí)行
例如:
$("#img").rotate({angle:45});
2.bind屬性:[Object] 對象,包含綁定到一個旋轉(zhuǎn)對象的事件。事件內(nèi)部的$(this)指向旋轉(zhuǎn)對象-這樣你可以在內(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)前角度值動畫旋轉(zhuǎn)到給定的角度值 (或給定的角度參數(shù))例如: 結(jié)合上面的例子,請參閱使用。
4.duration屬性:[Number] – 指定使用animateTo的動畫執(zhí)行持續(xù)時間例如 (click on arrow):
$("#img").rotate({bind:{
click: function(){
$(this).rotate({
duration:6000,
angle: 0,
animateTo:100
})
}
}
});
5.step屬性:[Function] – 每個動畫步驟中執(zhí)行的回調(diào)函數(shù),當(dāng)前角度值作為該函數(shù)的第一個參數(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] 動畫完成時執(zhí)行的回調(diào)函數(shù)例如 (click on arrow):
$("#img").rotate({bind:{
click: function(){
$(this).rotate({
angle: 0,
animateTo:180,
callback: function(){ alert(1) }
})
}
}
});
getRotateAngle
這個函數(shù)只是簡單地返回旋轉(zhuǎn)對象當(dāng)前的角度。
例如:
$("#img").rotate({
angle: 45,
bind: {
click : function(){
alert($(this).getRotateAngle());
}
}
});
stopRotate
這個函數(shù)只是簡單地停止正在進(jìn)行的旋轉(zhuǎn)動畫。
例如:
$("#img").rotate({
bind: {
click: function(){
$("#img").rotate({
angle: 0,
animateTo: 180,
duration: 6000
});
setTimeout(function(){
$("#img").stopRotate();
}, 1000);
}
}
});
用這個可以實(shí)現(xiàn)很多關(guān)于旋轉(zhuǎn)的網(wǎng)頁特效,我用這個做了個抽獎大轉(zhuǎn)盤,效果不錯,就是沒flash順暢,基本能跑哈哈。
jqueryrotate項目地址:http://code.google.com/p/jqueryrotate/
代碼示例:http://code.google.com/p/jqueryrotate/wiki/Examples
一步一步往上爬
相關(guān)文章
淺談jquery點(diǎn)擊label觸發(fā)2次的問題
下面小編就為大家?guī)硪黄獪\談jquery點(diǎn)擊label觸發(fā)2次的問題。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2016-06-06簡單易擴(kuò)展可控性強(qiáng)的Jquery轉(zhuǎn)盤抽獎程序
今天小編就為大家分享一篇關(guān)于簡單易擴(kuò)展可控性強(qiáng)的Jquery轉(zhuǎn)盤抽獎程序,小編覺得內(nèi)容挺不錯的,現(xiàn)在分享給大家,具有很好的參考價值,需要的朋友一起跟隨小編來看看吧2019-03-03JQuery的ready函數(shù)與JS的onload的區(qū)別詳解
這篇文章主要介紹了JQuery的ready函數(shù)與JS的onload的區(qū)別,有需要的朋友可以參考一下2013-11-11運(yùn)用jQuery寫的驗證表單(實(shí)例講解)
下面小編就為大家?guī)硪黄\(yùn)用jQuery寫的驗證表單(實(shí)例講解)。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2017-07-07jQuery + html + css 實(shí)現(xiàn)王者榮耀官網(wǎng)首頁效果&nb
這篇文章主要介紹了jQuery + html + css 實(shí)現(xiàn)王者榮耀官網(wǎng)首頁效果,本文通過實(shí)例代碼給大家介紹的非常詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友可以參考下2022-02-02jQuery實(shí)現(xiàn)漂亮實(shí)用的商品圖片tips提示框效果(無圖片箭頭+陰影)
這篇文章主要介紹了jQuery實(shí)現(xiàn)漂亮實(shí)用的商品圖片tips提示框效果,具有鼠標(biāo)滑過顯示動態(tài)提示框的效果,涉及針對鼠標(biāo)事件的響應(yīng)及頁面元素動態(tài)操作技巧,需要的朋友可以參考下2016-04-04