$book.animate({
opacity: 0.25,
}).animate({
opacity: 0.5
}).animate({
opacity: 1
})
function Queue() {
this.dataStore = [];
this.enqueue = enqueue;
this.dequeue = dequeue;
this.first = first;
this.end = end;
this.toString = toString;
this.empty = empty;
}
///////////////////////////
// enqueue()方法向队尾添加一个元素: //
///////////////////////////
function enqueue(element) {
this.dataStore.push(element);
}
/////////////////////////
// dequeue()方法删除队首的元素: //
/////////////////////////
function dequeue() {
return this.dataStore.shift();
}
/////////////////////////
// 可以使用如下方法读取队首和队尾的元素: //
/////////////////////////
function first() {
return this.dataStore[0];
}
function end() {
return this.dataStore[this.dataStore.length - 1];
}
/////////////////////////////
// toString()方法显示队列内的所有元素 //
/////////////////////////////
function toString() {
var retStr = "";
for (var i = 0; i < this.dataStore.length; ++i) {
retStr += this.dataStore[i] + "\n";
}
return retStr;
}
////////////////////////
// 需要一个方法判断队列是否为空 //
////////////////////////
function empty() {
if (this.dataStore.length == 0) {
return true;
} else {
return false;
}
}
var q = new Queue();
q.enqueue("Aaron1");
q.enqueue("Aaron2");
q.enqueue("Aaron3");
console.log("队列头: " + q.first()); //("Aaron1");
console.log("队列尾: " + q.end()); //("Aaron3");
<div id="div1" style="width:100px;height:50px;background:red;cursor:pointer;color:#fff;text-align:center;line-height:50px;">点击</div>
(function($) {
window.$ = $;
})(function() {
var rquickExpr = /^(?:#([\w-]*))$/;
function aQuery(selector) {
return new aQuery.fn.init(selector);
}
/**
* 动画
* @return {[type]} [description]
*/
var animation = function() {
var self = {};
var Queue = []; //动画队列
var fireing = false //动画锁
var first = true; //通过add接口触发
var getStyle = function(obj, attr) {
return obj.currentStyle ? obj.currentStyle[attr] : getComputedStyle(obj, false)[attr];
}
var makeAnim = function(element, options, func) {
var width = options.width
//包装了具体的执行算法
//css3
//setTimeout
element.style.webkitTransitionDuration = '2000ms';
element.style.webkitTransform = 'translate3d(' + width + 'px,0,0)';
//监听动画完结
element.addEventListener('webkitTransitionEnd', function() {
func()
});
}
var _fire = function() {
//加入动画正在触发
if (!fireing) {
var onceRun = Queue.shift();
if (onceRun) {
fireing = true;
//next
onceRun(function() {
fireing = false;
_fire();
});
} else {
fireing = true;
}
}
}
return self = {
//增加队列
add: function(element, options) {
Queue.push(function(func) {
makeAnim(element, options, func);
});
//如果有一个队列立刻触发动画
if (first && Queue.length) {
first = false;
self.fire();
}
},
//触发
fire: function() {
_fire();
}
}
}();
aQuery.fn = aQuery.prototype = {
run: function(options) {
animation.add(this.element, options);
return this;
}
}
var init = aQuery.fn.init = function(selector) {
var match = rquickExpr.exec(selector);
var element = document.getElementById(match[1])
this.element = element;
return this;
}
init.prototype = aQuery.fn;
return aQuery;
}());
//dom
var oDiv = document.getElementById('div1');
//调用
oDiv.onclick = function() {
$('#div1').run({
'width': '500'
}).run({
'width': '300'
}).run({
'width': '1000'
});
};
<!doctype html><div id="div1" style="width:100px;height:50px;background:red;cursor:pointer;color:#fff;text-align:center;line-height:50px;" data-mce-style="width: 100px; height: 50px; background: red; cursor: pointer; color: #fff; text-align: center; line-height: 50px;">点击</div><script type="text/javascript">
(function($) {
window.$ = $;
})(function() {
var rquickExpr = /^(?:#([\w-]*))$/;
function aQuery(selector) {
return new aQuery.fn.init(selector);
}
/**
* 动画
* @return {[type]} [description]
*/
var animation = function() {
var self = {};
var Queue = []; //动画队列
var fireing = false //动画锁
var first = true; //通过add接口触发
var getStyle = function(obj, attr) {
return obj.currentStyle ? obj.currentStyle[attr] : getComputedStyle(obj, false)[attr];
}
var makeAnim = function(element, options, func) {
var width = options.width
//包装了具体的执行算法
//css3
//setTimeout
element.style.webkitTransitionDuration = '2000ms';
element.style.webkitTransform = 'translate3d(' + width + 'px,0,0)';
//监听动画完结
element.addEventListener('webkitTransitionEnd', function() {
func()
});
}
var _fire = function() {
//加入动画正在触发
if (!fireing) {
var onceRun = Queue.shift();
if (onceRun) {
fireing = true;
//next
onceRun(function() {
fireing = false;
_fire();
});
} else {
fireing = true;
}
}
}
return self = {
//增加队列
add: function(element, options) {
Queue.push(function(func) {
makeAnim(element, options, func);
});
//如果有一个队列立刻触发动画
if (first && Queue.length) {
first = false;
self.fire();
}
},
//触发
fire: function() {
_fire();
}
}
}();
aQuery.fn = aQuery.prototype = {
run: function(options) {
animation.add(this.element, options);
return this;
}
}
var init = aQuery.fn.init = function(selector) {
var match = rquickExpr.exec(selector);
var element = document.getElementById(match[1])
this.element = element;
return this;
}
init.prototype = aQuery.fn;
return aQuery;
}());
//dom
var oDiv = document.getElementById('div1');
//调用
oDiv.onclick = function() {
$('#div1').run({
'width': '500'
}).run({
'width': '300'
}).run({
'width': '1000'
});
};
</script>
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有