animator.js
来自「php绿色服务器,让大家试用greenamp」· JavaScript 代码 · 共 484 行 · 第 1/2 页
JS
484 行
this.addElements(els);
this.syncAnims = true;
};
Ext.AnimatorComposite.prototype = {
isComposite: true,
/**
* Adds elements to this composite.
* @param {Array} els An array of elements to add
* @return {AnimatorComposite} this
*/
addElements : function(els){
if(!els) return this;
var anim = this.animator;
for(var i = 0, len = els.length; i < len; i++) {
anim.addActor(new Ext.Actor(els[i]));
}
anim.startCapture();
return this;
},
/**
* Operations called after sequence() will be performed one by one on each element in this composite.
* @return {AnimatorComposite} this
*/
sequence : function(){
this.syncAnims = false;
return this;
},
/**
* Operations called after sync() will be performed at the same time on each element in this composite.
* @return {AnimatorComposite} this
*/
sync : function(){
this.syncAnims = true;
return this;
},
invoke : function(fn, args){
var els = this.animator.actors;
if(this.syncAnims) this.animator.beginSync();
for(var i = 0, len = els.length; i < len; i++) {
Ext.Actor.prototype[fn].apply(els[i], args);
}
if(this.syncAnims) this.animator.endSync();
return this;
},
/**
* Play the actions queued in this composite.
* @param {Function} callback (optional) callback is called when all animations have compelted
* @return {AnimatorComposite} this
*/
play : function(callback){
this.animator.play(callback);
return this;
},
/**
* Clear all actions in the queue.
* @param {Function} callback (optional) callback is called when all animations have compelted
* @return {AnimatorComposite} this
*/
reset : function(callback){
this.animator.startCapture(true);
return this;
},
/**
* Add a pause
* @param {Number} seconds
* @return {AnimatorComposite} this
*/
pause : function(seconds){
this.animator.pause(seconds);
return this;
},
/**
* Get the Ext.Animator that controls the animations for this composite.
* @return {Ext.Animator}
*/
getAnimator : function(){
return this.animator;
},
/**
* Calls the passed function passing (el, this, index) for each element in this composite.
* @param {Function} fn The function to call
* @param {Object} scope (optional) The <i>this</i> object (defaults to the element)
* @return {AnimatorComposite} this
*/
each : function(fn, scope){
var els = this.animator.actors;
if(this.syncAnims) this.animator.beginSync();
for(var i = 0, len = els.length; i < len; i++){
fn.call(scope || els[i], els[i], this, i);
}
if(this.syncAnims) this.animator.endSync();
return this;
},
/**
* Add a function call to the playlist.
* @param {Function} fcn The function to call
* @param {Array} args (optional) The arguments to call the function with
* @param {Object} scope (optional) The scope of the function
* @return {AnimatorComposite} this
*/
addCall : function(fcn, args, scope){
this.animator.addCall(fcn, args, scope);
return this;
},
/**
* Add an async function call to the playlist.
* @param {Function} fcn The function to call
* @param {Number} callbackIndex The index of the callback parameter on the passed function. <b>A CALLBACK IS REQUIRED</b>.
* @param {Array} args (optional) The arguments to call the function with
* @param {Object} scope (optional) The scope of the function
* @return {AnimatorComposite} this
*/
addAsyncCall : function(fcn, callbackIndex, args, scope){
this.animator.addAsyncCall(fcn, callbackIndex, args, scope);
return this;
}
};
for(var fnName in Ext.Actor.prototype){
if(typeof Ext.Actor.prototype[fnName] == "function"){
Ext.CompositeElement.createCall(Ext.AnimatorComposite.prototype, fnName);
}
}
Ext.Animator.AnimSequence = function(){
this.actions = [];
this.nextDelegate = this.next.createDelegate(this);
this.playDelegate = this.play.createDelegate(this);
this.oncomplete = null;
this.playing = false;
this.stopping = false;
this.actionIndex = -1;
};
Ext.Animator.AnimSequence.prototype = {
add : function(action){
this.actions.push(action);
},
next : function(){
if(this.stopping){
this.playing = false;
if(this.oncomplete){
this.oncomplete(this, false);
}
return;
}
var nextAction = this.actions[++this.actionIndex];
if(nextAction){
nextAction.play(this.nextDelegate);
}else{
this.playing = false;
if(this.oncomplete){
this.oncomplete(this, true);
}
}
},
play : function(oncomplete){
if(this.playing) return; // can't play the same sequence twice at once
this.oncomplete = oncomplete;
this.stopping = false;
this.playing = true;
this.actionIndex = -1;
this.next();
},
stop : function(){
this.stopping = true;
},
isPlaying : function(){
return this.playing;
},
clear : function(){
this.actions = [];
},
addCall : function(fcn, args, scope){
this.actions.push(new Ext.Actor.Action(scope, fcn, args || []));
},
addAsyncCall : function(fcn, callbackIndex, args, scope){
this.actions.push(new Ext.Actor.AsyncAction(scope, fcn, args || [], callbackIndex));
},
pause : function(seconds){
this.actions.push(new Ext.Actor.PauseAction(seconds));
}
};
Ext.Animator.CompositeSequence = function(){
this.sequences = [];
this.completed = 0;
this.trackDelegate = this.trackCompletion.createDelegate(this);
};
Ext.Animator.CompositeSequence.prototype = {
add : function(sequence){
this.sequences.push(sequence);
},
play : function(onComplete){
this.completed = 0;
if(this.sequences.length < 1){
if(onComplete)onComplete();
return;
}
this.onComplete = onComplete;
for(var i = 0; i < this.sequences.length; i++){
this.sequences[i].play(this.trackDelegate);
}
},
trackCompletion : function(){
++this.completed;
if(this.completed >= this.sequences.length && this.onComplete){
this.onComplete();
}
},
stop : function(){
for(var i = 0; i < this.sequences.length; i++){
this.sequences[i].stop();
}
},
isPlaying : function(){
for(var i = 0; i < this.sequences.length; i++){
if(this.sequences[i].isPlaying()){
return true;
}
}
return false;
}
};
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?