zl程序教程

您现在的位置是:首页 >  前端

当前栏目

jQuery旋转插件jqueryrotate,制作转盘

jQuery插件 制作 旋转
2023-09-14 08:56:48 时间
下载地址:http://download.csdn.net/detail/cometwo/9478526

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 做演示,图片如下,请注意对比,不要看花眼了。

Google Chrome

演示1 直接旋转一个角度 Google Chrome

$(#img1).rotate(45);

$(#img1).rotate({angle:45});
演示2 鼠标移动效果 Google Chrome

$(#img2).rotate({ 

    bind : {

        mouseover : function(){

            $(this).rotate({animateTo: 180});

        }, mouseout : function(){

            $(this).rotate({animateTo: 0});

        }

    }

});
演示3 不停旋转 Google Chrome

var angle = 0;

setInterval(function(){

    angle +=3;

    $(#img3).rotate(angle);

}, 50);
Google Chrome

var rotation = function (){

    $(#img4).rotate({

        angle: 0, 

        animateTo: 360, 

        callback: rotation

    });

rotation();
Google Chrome

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 点击旋转 Google Chrome

$(#img6).rotate({ 

    bind: {

        click: function(){

            $(this).rotate({

                angle: 0,

                animateTo: 180,

                easing: $.easing.easeInOutExpo

            });

        }

    }

});
Google Chrome

var value2 = 0;

$(#img7).rotate({ 

    bind: {

        click: function(){

            value2 +=90;

            $(this).rotate({

                animateTo: value2

            });

        }

    }

});

演示虽然使用的是图片,但 jqueryrotate 并不只是能运用在图片上,其他元素如 div 等也可以使用。同时,你可以发挥想象,制作出更多关于旋转的特效。