jQuery 延迟插件 jWait
- 授权协议: MIT
- 开发语言: JavaScript
- 操作系统: 跨平台
- 软件首页: https://github.com/justinzzc/jWait
- 软件文档: https://github.com/justinzzc/jWait/blob/master/README.md
- 官方下载: https://github.com/justinzzc/jWait/archive/master.zip
软件介绍
jWait,a jquery plugin ,which provide a easy way to delay your work。
jQuery(zepto) 插件,把各种延迟串联起来,采用管道式写法 — 为了少写几个 setTimeout。
示例代码
原来
setTimeout(function (){
$('#b_1').addClass('active');
},1000);
现在
$('#b_1').jWait(1000).addClass('active');
原来
setTimeout(function (){
$('#b_1').addClass('active');
setTimeout(function (){
$('#b_2').css({color:red});
},1000);
},1000);
==> 现在
$('#b_1').jWait(1000)
.addClass('active')
.jWait(1000)
.jWait('#b_2').css({color:red});
原来
function doSth(){
//...
}
setTimeout(function (){
$('#b_1').addClass('active');
doSth();
setTimeout(function (){
doSth();
$('#b_2').css({color:red});
},1000);
},1000);
==> 现在
function doSth(){
//...
}
$('#b_1').jWait(1000)
.addClass('active')
.jWait(doSth)
.jWait(1000)
.jWait(doSth)
.jWait('#b_2').css({color:red});
简单图解
$('#b_1').jWait(1000)
.addClass('active') //$('#b_1').addClass('active')
.jWait(1000)
.fadeIn() //$('#b_1').fadeIn()
.jWait('#b_2')//修改代理的对象为 $('#b_2')
.jWait(1000)
.css({color:'red'})//$('#b_2').css({color:'red'})
.jWait(function (){
//这里获取当前代理对象 this ==> $('#b_2')
console.log(this.css('color'));
})
.jWait(console)//修改代理的对象为 console
.log('hello') //console.log('hello')
.error('error');//console.error('error');
参数
/**
** @param waitObj 绑定对象可以是 (数字,字符串,对象,方法)
* 1.数字 表示延迟的时间(单位:毫秒)
* 2.字符串 查询字符串querySelector,表示切换代理的对象为查询字符串代表的jquery对象
* 3.对象 代理的对象,表示切换代理的对象
* 4.方法 延迟后执行的函数,如果没有延迟,则直接执行
** @param callback 回调方法,只有当waitObj是数字类型时有效
* @returns {jWaitProxy} 返回一个执行代理对象,一个神奇的对象
*/
$.fn.jWait = function (waitObj, callback) { //.... }
perl进阶
Randal L.Schwartz、brian d.foy、Tom Phoenix / 韩雷 / 人民邮电出版社 / 2015-10-1 / 69
本书是Learning Perl一书的进阶。学完本书之后,您可以使用Perl语言的特性编写从简单脚本到大型程序在内的所有程序,正是Perl语言的这些特性使其成为通用的编程语言。本书为读者深入介绍了模块、复杂的数据结构以及面向对象编程等知识。 本书每章的篇幅都短小精悍,读者可以在一到两个小时内读完,每章末尾的练习有助于您巩固在本章所学的知识。如果您已掌握了Learning Perl中的内容并渴......一起来看看 《perl进阶》 这本书的介绍吧!
