jequry_rotate.js用来写旋转类的东西的插件(如:抽奖转盘)
网上发现一个很有意思的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] 包含旋转参数的对象。支持的属性:
- angle属性:[Number] – default 0 – 旋转的角度数,并且立即执行例如:
1
$("#img").rotate({angle:45}); - 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 }) } } }); - animateTo属性:[Number] – default 0 – 从当前角度值动画旋转到给定的角度值 (或给定的角度参数)例如: 结合上面的例子,请参阅使用。
- 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 }) } } }); - step属性:[Function] – 每个动画步骤中执行的回调函数,当前角度值作为该函数的第一个参数
- 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 }) } } }); - 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用来写旋转类的东西的插件(如:抽奖转盘)的更多相关文章
- 原生JS动态添加和删除类
原生JS动态添加和删除类 由于需要, 给按钮组监听点击事件(要求用事件委托),当有一个按钮被点击时,相应的给该按钮添加一个类(激活类),其他没有点击的按钮就要移出该类 添加和和删除类有三种方法 首先等 ...
- js面向对象设计之class类
class 相对 function 是后出来的,既然 class 出来了,显然是为了解决 function 在处理面向对象设计中的缺陷而来.下面通过对比,来看看 class 作为 ES6 中的重大升级 ...
- 几道JS代码手写面试题
几道JS代码手写面试题 (1) 高阶段函数实现AOP(面向切面编程) Function.prototype.before = function (beforefn) { let ...
- java能不能自己写一个类叫java.lang.System/String正确答案
原文: http://www.wfuyu.com/php/22254.html 未做测试 ! 最近学习了下java类加载相干的知识.然后看到网上有1道面试题是 能不能自己写个类叫java.lang.S ...
- Java基础-接口.编写2个接口:InterfaceA和InterfaceB;在接口InterfaceA中有个方法void printCapitalLetter();在接口InterfaceB中有个方法void printLowercaseLetter();然 后写一个类Print实现接口InterfaceA和InterfaceB,要求 方法 实现输出大写英文字母表的功能,printLowerca
#34.编写2个接口:InterfaceA和InterfaceB:在接口InterfaceA中有个方法void printCapitalLetter():在接口InterfaceB中有个方法void ...
- 如何用ActiveQt写导出类
如何用ActiveQt写导出类 最近一直在用ActiveQt框架来写ActiveX插件, 由于项目需要提示类的导出, 所以上午捣鼓了一下, 现在记录记录.其实内容主要是把Qt手册里自己用到的部分整理一 ...
- [置顶] 自己写sqlhelper类
自己写sqlhelper类 using System; using System.Collections.Generic; using System.Configuration; using Syst ...
- JS基于时间戳写的浏览访问人数
Title:JS基于时间戳写的浏览访问人数 --2013-12-23 14:07 <script language="JavaScript"> var timesta ...
- 《JS权威指南学习总结--9.3 JS中JAVA式的类继承》
内容要点: 一.JS中的类 1.JAVA或其他类似强类型 面向对象语言的 类成员的模样 实例字段:它们是基于实例的属性或变量,用以保存独立对象的状态. 实例方法: 它们是类的所有实例所共享的方法,由每 ...
随机推荐
- [BZOJ3523][Poi2014]KLO-Bricks——全网唯一 一篇O(n)题解+bzoj最优解
Description 有n种颜色的砖块,第i种颜色的砖块有a[i]个,你需要把他们放成一排,使得相邻两个砖块的颜色不相同,限定第一个砖块的颜色是start,最后一个砖块的颜色是end,请构造出一种合 ...
- android源码了解dex加载流程
源码版本:4.4.4_r1 http://www.cnblogs.com/lanrenxinxin/p/4712224.html http://wangzhixian.org/Others/DexCl ...
- some interesting words
No one gets rich betting against the market. Never bet against the Fed. Bulls make money, bears make ...
- How Many Nines ZOJ - 3950 打表大法好
If we represent a date in the format YYYY-MM-DD (for example, 2017-04-09), do you know how many 9s w ...
- udhcpd源码分析2--读取配置文件
1:重要的结构体 读取配置文件信息到全局的结构体struct server_config_t server_config中,这个结构在很多文件中都有引用到很重要. /* dhcpd.h */ stru ...
- ExecuteNonQuery,ExecuteReader,ExecuteScalar 区别
ExecuteNonQuery方法 :执行非查询SQL操作,包括增insert.删delete.改update ExcuteReader方法 :执行查询,返回DataReader,通过DataRead ...
- linux时区修定转
https://blog.csdn.net/feng12345zi/article/details/80348501
- Spring Data JPA 的使用(山东数漫江湖)
pring data jpa介绍 什么是JPA JPA(Java Persistence API)是Sun官方提出的Java持久化规范.它为Java开发人员提供了一种对象/关联映射工具来管理Java应 ...
- HDU 2546 饭卡 (dp)
题目链接 Problem Description 电子科大本部食堂的饭卡有一种很诡异的设计,即在购买之前判断余额.如果购买一个商品之前,卡上的剩余金额大于或等于5元,就一定可以购买成功(即使购买后卡上 ...
- HDU 1114 Piggy-Bank (dp)
题目链接 Problem Description Before ACM can do anything, a budget must be prepared and the necessary fin ...