首頁  >  文章  >  web前端  >  jQuery旋轉插件—rotate支援(ie/Firefox/SafariOpera/Chrome)_jquery

jQuery旋轉插件—rotate支援(ie/Firefox/SafariOpera/Chrome)_jquery

WBOY
WBOY原創
2016-05-16 17:43:251159瀏覽

網路上發現一個很有趣的jQuery旋轉插件,支援Internet Explorer 6.0 、Firefox 2.0 、Safari 3 、Opera 9 、Google Chrome,進階瀏覽器下使用Transform,低版本ie使用VML實作。

呼叫與方法:

rotate(angle)

angle參數:[Number] – 預設為0 – 根據給定的角度旋轉圖片

例如:

複製程式碼 程式碼如下:


程式碼如下:

$
$ img").rotate(45);


rotate(parameters)

parameters參數:[Object] 包含旋轉參數的物件。支援的屬性:
複製程式碼

程式碼如下:
$("#img").rotate({angle:45});
複製程式碼


程式碼如下:


$("#img ").rotate({bind:{

click: function(){

$(this).rotate({

angle: 0,

animateTo:180
})
} } });

3.animateTo屬性
:[Number] – default 0 –從當前角度值動畫旋轉到給定的角度值(或給定的角度參數)例如: 結合上面的例子,請參閱使用。 4.duration屬性:[Number] – 指定使用animateTo的動畫執行持續時間例如(click on arrow):
複製程式碼


程式碼如下:


$("#img").rotate({bind:{
click: function(){
$(this(this ).rotate({
duration:6000,
angle: 0,
animateTo:100
})
} } });

程式碼如下:


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] 動畫完成時執行的回呼函數例如(click on arrow):



複製程式碼


程式碼如下:


$("#img").rotate({bind:{ click: function(){
$(this).rotate({
angle: 0,
animateTo:180,
callback: function(){ alert(1) } } ) }
}
});


複製程式碼 程式碼如下:

$("#img").rotate({
angle: 45,
bind: {
click : function(){
alert($(this).getRotateAngle ());
}
}
});

stopRotate

這個函數只是簡單地停止正在進行的旋轉動畫。

例如:
複製程式碼 程式碼如下:


程式碼如下:


$
$ img").rotate({
bind: {
click: function(){
$("#img").rotate({
angle: 0,
animateTo: 180,
duration: 6000
});
setTimeout(function(){
$("#img").stopRotate();
}, 1000);
}
}
}
}
}
}
} } } } } } } } } } } } ) >} });用這個可以實現很多關於旋轉的網頁特效,我用這個做了個抽獎大轉盤,效果不錯,就是沒flash順暢,基本能跑哈哈。 jqueryrotate專案位址:http://code.google.com/p/jqueryrotate/ 程式碼範例:http://code.google.com/p/jqueryrotate/wiki/Examples 一步一步往上爬
陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn