jQuery旋转插件—rotate详细使用说明文档

2015-10-19  本文已影响12428人  0x584A

jQuery旋转插件—rotate详细说明文档

By:0x584A Date:2015年10月19日 21:10:27

参数

参数 类型 说明 默认值
angle 数字 旋转一个角度 0
animateTo 数字 从当前的角度旋转到多少度 0
step 函数 每个动画步骤中执行的回调函数,当前角度值作为该函数的第一个参数
easing 函数 自定义旋转速度、旋转效果,需要使用 jQuery.easing.js
duration 整数 旋转持续时间,以毫秒为单位
callback 函数 旋转完成后的回调函数
getRotateAngle 函数 返回旋转对象当前的角度
stopRotate 函数 停止旋转

实现的效果:


1.gif

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);或 $('#img').rotate({angle:45})

rotate(parameters)parameters参数:[Object] 包含旋转参数的对象。

支持的属性:

例如:

$("#img").rotate({angle:45});

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


$("#img").rotate({
    bind:{
        click:function(){
            $(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 ;
}

Example1:没有效果,一直转

 $("#scImg").rotate({
    angle:0,
    animateTo:360,
    callback: rotation,
    easing: function (x,t,b,c,d){
            return (t/d)*c ;
    }
});

Example2: 默认的效果

$("#scImg").rotate({
    angle:0,
    animateTo:360,
    callback: rotation,
    easing: function (x,t,b,c,d){
        return -c*( (t=t/d-1)*t*t*t-1)+b ;
        }
    });

Example3:

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

$("#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());
        }
    }
});

$("#img").rotate({
    bind: {
        click: function(){
            $("#img").rotate({
                angle: 0,
                animateTo: 180,
                duration: 6000
            })
        }
    }
)};
上一篇 下一篇

猜你喜欢

热点阅读