网上发现一个很有意思的jQuery旋转插件,支持Internet Explorer 6.0+ 、Firefox 2.0 、Safari 3 、Opera 9 、Google Chrome,高级浏览器下使用Transform,低版本ie使用VML实现。

调用和方法:

rotate(angle)

angle参数:[Number] – 默认为 0 – 根据给定的角度旋转图片

例如:

1
$("#img").rotate(45);

rotate(parameters)

parameters参数:[Object] 包含旋转参数的对象。支持的属性:

  1. angle属性:[Number] – default 0 – 旋转的角度数,并且立即执行例如:

    1
    $("#img").rotate({angle:45});
  2. bind属性:[Object] 对象,包含绑定到一个旋转对象的事件。事件内部的$(this)指向旋转对象-这样你可以在内部链式调用- $(this).rotate(…)。例如 (click on arrow):
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    $("#img").rotate({
        bind: {
            click: function () {
                $(this).rotate({
                    angle: 0,
                    animateTo: 180
                })
            }
        }
    });
  3. animateTo属性:[Number] – default 0 – 从当前角度值动画旋转到给定的角度值 (或给定的角度参数)例如: 结合上面的例子,请参阅使用。
  4. duration属性:[Number] – 指定使用animateTo的动画执行持续时间例如 (click on arrow):
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    $("#img").rotate({
        bind: {
            click: function () {
                $(this).rotate({
                    duration: 6000,
                    angle: 0,
                    animateTo: 100
                })
            }
        }
    });
  5. step属性:[Function] – 每个动画步骤中执行的回调函数,当前角度值作为该函数的第一个参数
  6. easing属性:[Function] – 默认 (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:
    1
    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):

    1
    function(x, t, b, c, d) { return (t/d)*c ; }

    Example (click on arrow):

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    $("#img").rotate({bind: {
        click: function () {
            $(this).rotate({
                angle: 0,
                animateTo: 180,
                easing: $.easing.easeInOutElastic
            })
        }
    }
    });
  7. callback属性:[Function] 动画完成时执行的回调函数例如 (click on arrow):
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    $("#img").rotate({bind: {
     
        click: function () {
            $(this).rotate({
                angle: 0,
                animateTo: 180,
                callback: function () {
                    alert(1)
                }
            })
        }
    }
    });

getRotateAngle

这个函数只是简单地返回旋转对象当前的角度。

例如:

1
2
3
4
5
6
7
8
$("#img").rotate({
    angle: 45,
    bind: {
        click: function () {
            alert($(this).getRotateAngle());
        }
    }
});

stopRotate

这个函数只是简单地停止正在进行的旋转动画。

例如:

2
3
4
5
6
7
8
9
10
11
12
13
14
15
$("#img").rotate({
    bind: {
        click: function () {
            $("#img").rotate({
                angle: 0,
                animateTo: 180,
                duration: 6000
            });
            setTimeout(function () {
                $("#img").stopRotate();
            }, 1000);
        }
    }
});

jequry_rotate.js用来写旋转类的东西的插件(如:抽奖转盘)的更多相关文章

  1. 原生JS动态添加和删除类

    原生JS动态添加和删除类 由于需要, 给按钮组监听点击事件(要求用事件委托),当有一个按钮被点击时,相应的给该按钮添加一个类(激活类),其他没有点击的按钮就要移出该类 添加和和删除类有三种方法 首先等 ...

  2. js面向对象设计之class类

    class 相对 function 是后出来的,既然 class 出来了,显然是为了解决 function 在处理面向对象设计中的缺陷而来.下面通过对比,来看看 class 作为 ES6 中的重大升级 ...

  3. 几道JS代码手写面试题

    几道JS代码手写面试题   (1) 高阶段函数实现AOP(面向切面编程)    Function.prototype.before = function (beforefn) {        let ...

  4. java能不能自己写一个类叫java.lang.System/String正确答案

    原文: http://www.wfuyu.com/php/22254.html 未做测试 ! 最近学习了下java类加载相干的知识.然后看到网上有1道面试题是 能不能自己写个类叫java.lang.S ...

  5. Java基础-接口.编写2个接口:InterfaceA和InterfaceB;在接口InterfaceA中有个方法void printCapitalLetter();在接口InterfaceB中有个方法void printLowercaseLetter();然 后写一个类Print实现接口InterfaceA和InterfaceB,要求 方法 实现输出大写英文字母表的功能,printLowerca

    #34.编写2个接口:InterfaceA和InterfaceB:在接口InterfaceA中有个方法void printCapitalLetter():在接口InterfaceB中有个方法void ...

  6. 如何用ActiveQt写导出类

    如何用ActiveQt写导出类 最近一直在用ActiveQt框架来写ActiveX插件, 由于项目需要提示类的导出, 所以上午捣鼓了一下, 现在记录记录.其实内容主要是把Qt手册里自己用到的部分整理一 ...

  7. [置顶] 自己写sqlhelper类

    自己写sqlhelper类 using System; using System.Collections.Generic; using System.Configuration; using Syst ...

  8. JS基于时间戳写的浏览访问人数

    Title:JS基于时间戳写的浏览访问人数  --2013-12-23 14:07 <script language="JavaScript"> var timesta ...

  9. 《JS权威指南学习总结--9.3 JS中JAVA式的类继承》

    内容要点: 一.JS中的类 1.JAVA或其他类似强类型 面向对象语言的 类成员的模样 实例字段:它们是基于实例的属性或变量,用以保存独立对象的状态. 实例方法: 它们是类的所有实例所共享的方法,由每 ...

随机推荐

  1. POJ1375:Intervals——题解

    http://poj.org/problem?id=1375 题目大意:有一盏灯,求每段被圆的投影所覆盖的区间. —————————————————————— 神题,卡精度,尝试用各种方法绕过精度都不 ...

  2. bzoj 4206 最大团 几何+lis

    最大团 Time Limit: 10 Sec  Memory Limit: 256 MBSubmit: 142  Solved: 65[Submit][Status][Discuss] Descrip ...

  3. lightoj 1282 && uva 11029

    Leading and Trailing lightoj 链接:http://lightoj.com/volume_showproblem.php?problem=1282 uva 链接:http:/ ...

  4. python读书笔记-《A Byte of Python》中文第三版后半部分

    编辑器:windows,linux 不要用notepad,缩进糟糕 -------------- 5.18缩进 同一层次的语句必须有相同的缩进.每一组这样的语句称为一个块. i = 5 2  prin ...

  5. ssm项目,web容器无法初始化项目

    在web.xml中配置加载spring时,发现项目无法运行:而去掉spring的配置时,项目可以被初始化. 此时应考虑到spring的配置文件中存在错误,以至于web容器无法对项目成功初始化,在web ...

  6. JS利用 Sea.js 实现模块化:拖拽、缩放及范围限制

    知识点总结: Sea.js的使用:define.export.seajs.use.require等方法:   参考:http://seajs.org/docs/ Sea.js与require.js的区 ...

  7. 阿里C++研发实习二面和三面面经

    下午连着面了阿里爸爸的二面和三面,非常不明白别人的三面都是hr了,为什么我还是在技术面,难道面了个假阿里.不管怎么样,来篇面经攒攒人品. 二面 第一次遇到这么严肃的面试官,居然可以全程无表情的,面了这 ...

  8. [Luogu 1160] 队列安排

    Luogu 1160 队列安排 链表H2O H2O H2O模板. 太久不写链表,忘干净了,竟调了半个晚上. 保留备用. #include <cstdio> #include <cst ...

  9. jsp 内置对象(一)

    一.jsp的九大内置对象 内置对象 所属类 pageContext javax.servlet.jsp.PageContext request javax.servlet.http.HttpServl ...

  10. bzoj 1036: [ZJOI2008]树的统计Count——树链剖分

    Description 一棵树上有n个节点,编号分别为1到n,每个节点都有一个权值w.我们将以下面的形式来要求你对这棵树完成一些操作: I. CHANGE u t : 把结点u的权值改为t II. Q ...