jQuery旋轉外掛程式jqueryrotate

來源:互聯網
上載者:User

標籤:

http://www.dowebok.com/72.html

 

jQuery旋轉外掛程式jqueryrotate

分類:代碼 日期:2014-01-01 點擊(8,727) 評論(10)

CSS3 提供了多種變形效果,比如矩陣變形、位移、縮放、旋轉和傾斜等等,讓頁面更加生動活潑有趣,不再一動不動。然後 IE10 以下版本的瀏覽器不支援 CSS3 變形,雖然 IE 有私人屬性濾鏡(filter),但不全面,而且效果和效能都不好。

今天介紹一款 jQuery 外掛程式——jqueryrotate,它可以實現旋轉效果。jqueryrotate 支援所有主流瀏覽器,包括 IE6。如果你想在低版本的 IE 中實現旋轉效果,那麼 jqueryrotate 是一個很好的選擇。

相容性

jqueryrotate 支援所有主流瀏覽器,包括 IE6。jqueryrotate 在進階瀏覽器中使用 CSS3 transform 屬性實現,在低版本 IE 中使用 VML 實現。當然,你可以使用 IE 條件注釋,低版本 IE 使用 jqueryrotate,進階瀏覽器則直接使用 CSS3。

使用方法

我們使用 Google Chrome 的 Logo 做示範,圖片如下,請注意對比,不要看花眼了。

示範1 直接旋轉一個角度

$(‘#img1‘).rotate(45);

或

$(‘#img1‘).rotate({angle:45});
示範2 滑鼠移動效果

$(‘#img2‘).rotate({     bind : {        mouseover : function(){            $(this).rotate({animateTo: 180});        }, mouseout : function(){            $(this).rotate({animateTo: 0});        }    }});
示範3 不停旋轉

var angle = 0;setInterval(function(){    angle +=3;    $(‘#img3‘).rotate(angle);}, 50);

var rotation = function (){    $(‘#img4‘).rotate({        angle: 0,         animateTo: 360,         callback: rotation    });}rotation();

var rotation2 = function(){    $(‘#img5‘).rotate({        angle: 0,         animateTo: 360,         callback: rotation2,        easing: function(x,t,b,c,d){            return c*(t/d)+b;        }    });}rotation2();
示範4 點擊旋轉

$(‘#img6‘).rotate({     bind: {        click: function(){            $(this).rotate({                angle: 0,                animateTo: 180,                easing: $.easing.easeInOutExpo            });        }    }});

var value2 = 0;$(‘#img7‘).rotate({     bind: {        click: function(){            value2 +=90;            $(this).rotate({                animateTo: value2            });        }    }});
參數
參數 類型 說明 預設值
angle 數字 旋轉一個角度 0
animateTo 數字 從當前的角度旋轉到多少度 0
step 函數 每個動畫步驟中執行的回呼函數,當前角度值作為該函數的第一個參數 無
easing 函數 自訂旋轉速度、旋轉效果,需要使用 jQuery.easing.js 無
duration 整數 旋轉期間,以毫秒為單位  
callback 函數 旋轉完成後的回呼函數 無
getRotateAngle 函數 返迴旋轉對象當前的角度 無
stopRotate 函數 停止旋轉 無

示範雖然使用的是圖片,但 jqueryrotate 並不只是能運用在圖片上,其他元素如 div 等也可以使用。同時,你可以發揮想象,製作出更多關於旋轉的特效。

jQuery旋轉外掛程式jqueryrotate

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.