网上发现一个很有意思的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. 【BZOJ5297】【CQOI2018】社交网络(矩阵树定理)

    [BZOJ5297][CQOI2018]社交网络(矩阵树定理) 题面 BZOJ 洛谷 Description 当今社会,在社交网络上看朋友的消息已经成为许多人生活的一部分.通常,一个用户在社交网络上发 ...

  2. POJ1279:Art Gallery——题解

    http://poj.org/problem?id=1279 题目大意:给按照顺时针序的多边形顶点,问其内核可行区域面积. —————————————————————————————— 终于变了一点… ...

  3. FreeRTOS - 任务使用注意

    如果使用xTaskCreate() 创建任务,任务栈使用的是FreeRTOS heap

  4. CMDB资产管理系统开发【day26】:批准资产入库

    刚才都是一条像内存,硬盘,网卡.多条的话如何操作 只有一条数据 下面的是有多条数据的 硬盘必须字段的验证 def __create_disk_component(self): disk_info = ...

  5. js遇到问题汇总

    1.原生js获取同级的兄弟节点 <!DOCTYPE html> <html> <head> <meta charset="utf-8"&g ...

  6. webservice 针对WebService服务,客户端调用时报序列化的最大项数maxItemsInObjectGraph超过65536问题

    今天在使用webservice服务时候,报异常“The InnerException message was 'Maximum number of items that can be serializ ...

  7. 【BZOJ】1697: [Usaco2007 Feb]Cow Sorting牛排序

    [算法]数学置换 [题意]给定n个数,要求通过若干次交换两个数的操作得到排序后的状态,每次交换代价为两数之和,求最小代价. [题解] 考虑置换的定义:置换就是把n个数做一个全排列. 从原数组到排序数组 ...

  8. 【NOIP】提高组2012 国王游戏

    [题意] 恰逢H国国庆,国王邀请n位大臣来玩一个有奖游戏.首先,他让每个大臣在左.右 手上面分别写下一个整数,国王自己也在左.右手上各写一个整数.然后,让这n位大臣排 成一排,国王站在队伍的最前面.排 ...

  9. Codeforces Round #483 (Div. 2) [Thanks, Botan Investments and Victor Shaburov!]

    题目链接:http://codeforces.com/contest/984 A. Game time limit per test:2 seconds memory limit per test:5 ...

  10. 并查集入门--畅通工程(HDU1232)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1232 畅通工程 Time Limit: 4000/2000 MS (Java/Others)    M ...