jQuery-velocity.js 插件的简易使用
初识Velocity动画,感觉它并没有那么强大,但是渐渐感觉它的ui动画可以让我们简易的使用到我们的项目中。
Velocity动画的简介:
下载地址:http://www.julian.com/research/velocity/
兼容性:IE8 和 Android2.3
官网的配置代码:
require.config({
paths: {
"jquery": "/path/to/jquery-x.x.x",
"velocity": "path/to/velocity",
// Optional, if you're using the UI pack:
"velocity-ui": "path/to/velocity.ui"
},
shim: {
"velocity": {
deps:
[ "jquery" ]
},
// Optional, if you're using the UI pack:
"velocity-ui": {
deps:
[ "velocity" ]
}
}
});
require([ "jquery", "velocity", "velocity-ui" ], function ($, Velocity) {
/* Your
app code here. */
$("body").velocity({ opacity: 0.5 });
});
Velocity.js的基本用法:
1.引入jQuery.js库
2.引入velocity.min.js库
3.引入velocity.ui.min.js库
官网用法代码:
$element.velocity({
width: "500px",
property2: value2
}, {
/* Velocity's default options */
duration: 400,
easing: "swing",
queue: "",
begin: undefined,
progress: undefined,
complete: undefined,
display: undefined,
visibility: undefined,
loop: false,
delay: false,
mobileHA: true
});
第一个参数 为 CSS属性
第二个参数为 velocity 配置选项
duration : 400 动画时长
easing : “swing”
queue : “”
begin: undefined
progress: undefined
complete: undefined
display: undefined
visibility: undefined
loop: false
delay: false 动画延迟时间
mobileHA: true
制作动画序列的三种方法:
前面两种省略。
我想把最好的方式推荐给大家:
官网的示例代码:
var mySequence = [
{e: $element1, p: {translateX: 100}, o:{duration: 1000}},
{e: $element2, p: {translateX: 200}, o:{duration: 1000, sequenceQueue: false}},
{e: $element3, p: {translateX: 300}, o:{duration: 1000}}
];
$.Velocity.RunSequence(mySequence);
1.创建一个动画序列
var seq = [
{
elements : $('#div1'),
properties : { width: '300px' },
options : { duration : 1000 }
},
{
elements : $('#div1'),
properties : { width: '300px' },
options : { duration : 1000 }
},
{
elements : $('#div1'),
properties : { width: '300px' },
options : { duration : 1000 }
}
];
2.运行动画序列 seq
$.Velocity.RunSequence(seq);
预定义动画和自定义动画:
1.预定义动画
$('#div1').on('mouseover',function(){
$(this).velocity('callout.shake');
});
还有很多预定义动画,这里我根据官网一一列举一下:
callout.bounce
callout.shake
callout.flash
callout.pulse
callout.swing
Callout.tada
transition.fadeIn
transition.fadeOut
transition.flipXIn
transition.flipXOut
transition.flipYIn
transition.flipYOut
transition.flipBounceXIn
transition.flipBounceXOut
transition.flipBounceYIn
transition.flipBounceYOut
transition.swoopIn
transition.swoopOut
transition.whirlIn
transition.whirlOut
transition.shrinkIn
transition.shrinkOut
transition.expandIn
transition.expandOut
transition.bounceIn
transition.bounceOut
transition.bounceUpIn
transition.bounceUpOut
transition.bounceDownIn
transition.bounceDownOut
transition.bounceLeftIn
transition.bounceLeftOut
transition.bounceRightIn
transition.bounceRightOut
transition.slideUpIn
transition.slideUpOut
transition.slideDownIn
transition.slideDownOut
transition.slideLeftIn
transition.slideLeftOut
transition.slideRightIn
transition.slideRightOut
transition.slideUpBigIn
transition.slideUpBigOut
transition.slideDownBigIn
transition.slideDownBigOut
transition.slideLeftBigIn
transition.slideLeftBigOut
transition.slideRightBigIn
transition.slideRightBigOut
transition.perspectiveUpIn
transition.perspectiveUpOut
transition.perspectiveDownIn
transition.perspectiveDownOut
transition.perspectiveLeftIn
transition.perspectiveLeftOut
transition.perspectiveRightIn
transition.perspectiveRightOut
2.自定义动画:
官网推荐代码:
$.Velocity.RegisterEffect(name,{
defaultDuration : duration ,
calls : [
[ { property : value }, durationPercentage, {options} ],
[ { property : value }, durationPercentage, {options} ]
],
reset : { property : value, property : value }
});
下面是我写的代码:
$.Velocity.RegisterEffect ( 'jiangbo.pulse', {
defaultDuration : 300,
calls : [
[ { scaleX : 1.1 }, 0.5 ],
[ { scaleX : 1.0 }, 0.5 ]
]
} );
$('#div1').on('mouseover',function(){
$(this).velocity('jiangbo.pulse');
});
jQuery-velocity.js 插件的简易使用的更多相关文章
- 【PC端】jQuery+PHP实现浏览更多内容(jquery.more.js插件)
参数说明: 'amount' : '10', //每次显示记录数 'address' : 'comments.php', //请求后台的地址 'format' : 'json', //数据传输格式 ' ...
- jQuery.cookie.js插件了解及使用方法
jquery.cookie.js插件实现浏览器的cookie存储,该插件是基于jquery开发,方便cookie使用. jquerycookie.js的下载地址 http://plugins.jque ...
- 购物车增加、减少商品时动画效果:jQuery.Fly.js插件使用方法
某些电商网站加入购物车和减少购物车商品数量时,有个小动画,以抛物线形式增减,如图: 这里用到了第三方jQuery.Fly.js插件(底层依赖Jquery库,地址:https://github ...
- jquery.autocomplete.js 插件的自定义搜索规则
这二天开始用jquery.autocomplete这个自动完成插件.功能基本比较强大,但自己在实际需求中发现还是有一处不足!问题是这样:当我定义了一个本地数据JS文件时,格式为JSON式的数组.如下: ...
- 异步上传图片,光用jquery不行,得用jquery.form.js插件
异步上传图片,光用jquery不行,得用jquery.form.js插件,百度一下下载这个插件,加jquery,引入就可以了 <form id="postbackground" ...
- 整屏滚动效果 jquery.fullPage.js插件+CSS3实现
最近很流行整屏滚动的效果,无论是在PC端还是移动端,本人也借机学习了一下,主要通过jquery.funnPage.js插件+CSS3实现效果. 本人做的效果: PC端:http://demo.qpdi ...
- ajax请求执行完成后再执行其他操作(jQuery.page.js插件使用为例)
就我们做知,ajax强大之处在于它的异步请求,但是有时候我们需要ajax执行彻底完成之后再执行其他函数或操作 这个时候往往我们用到ajax的回调函数,但是假如你不想或者不能把接下来的操作写在回调函数中 ...
- jquery.validate.js插件的使用方法
近期做项目.须要用到 jQuery.validate.js插件,于是记录一下工作中的一些经验,以便日后学习. [样例例如以下] 1.前台页面 <form id="form1" ...
- jQuery通过jquery.form.js插件使用AJAX提交Form表单
我简单使用了一下,jQuery Form插件有一下优点: 1.支持提交前验证. 2.支持提交后回调. 3.采用AJAX方式,有很好的用户体验 4.提交方式是灵活.只要指定要提交的form ID即可. ...
随机推荐
- [Android] 基于 Linux 命令行构建 Android 应用(七):自动化构建
本章将演示如何基于 Linux 命令行构建 Android 应用,在开始本章之前,希望你已经阅读之前几章内容. 本文环境为 RHEL Sandiego 32-bits,要基于 Linux CLI 构建 ...
- Linux-C实现GPRS模块发送短信
“GSM模块,是将GSM射频芯片.基带处理芯片.存储器.功放器件等集成在一块线路板上,具有独立的操作系统.GSM射频处理.基带处理并提供标准接口的功能模块.GSM模块根据其提供的数据传输速率又可以分为 ...
- c++11 auto 与 decltype 详解
转自: here 一. auto简介 编程时候常常需要把表达式的值付给变量,需要在声明变量的时候清楚的知道变量是什么类型.然而做到这一点并非那么容易(特别是模板中),有时候根本做不到.为了解决这个问题 ...
- sonar-scanner的执行流程和对ClassLoader,动态代理的使用
最近项目上使用了sonarqube来提供静态代码检查的服务,在看sonar-scanner的源码的时候,发现sonar-scanner用来分析的jar包是从sonar的服务器上下载下来的,使用自定义的 ...
- [转]获取app的内部储存路径
首先内部存储路径为/data/data/youPackageName/,下面讲解的各路径都是基于你自己的应用的内部存储路径下.所有内部存储中保存的文件在用户卸载应用的时候会被删除. 一. files1 ...
- day_4_24 py
''' 函数的嵌套调用应用 ''' # def print_line(): # print("="*50) # def print_5_line(): # i = 0 # whil ...
- day_5.20 py
列表去重的两种方法 1.自己写程序 for循环 2.直接变为set类型
- F - Unix ls
The computer company you work for is introducing a brand new computer line and is developing a new U ...
- CSS3 transition 属性过渡效果 详解
CSS3 transition 允许 CSS 元素的属性值在一定的时间区间内平滑地过渡.我们可以在不使用 Flash 动画或 JavaScript 的情况下,在元素从一种样式变换为另一种样式时为元素添 ...
- IBatisNet不常用到的配置(Dao.config ConnectionTimeout),居然不起作用(前辈留给我们的坑)
IBattis 默认超时时间好像是30s,可多于这个时间总就会报错:DaoProxy : unable to intercept method name 'ExcuteQuery', cause : ...