📄 fx.js
字号:
el.shift({
width: [element's width],
height: [element's height],
x: [element's x position],
y: [element's y position],
opacity: [element's opacity],
easing: 'easeOut',
duration: .35
});
</code></pre>
* @param {Object} options Object literal with any of the Fx config options
* @return {Ext.Element} The Element
*/
shift : function(o){
var el = this.getFxEl();
o = o || {};
el.queueFx(o, function(){
var a = {}, w = o.width, h = o.height, x = o.x, y = o.y, op = o.opacity;
if(w !== undefined){
a.width = {to: this.adjustWidth(w)};
}
if(h !== undefined){
a.height = {to: this.adjustHeight(h)};
}
if(o.left !== undefined){
a.left = {to: o.left};
}
if(o.top !== undefined){
a.top = {to: o.top};
}
if(o.right !== undefined){
a.right = {to: o.right};
}
if(o.bottom !== undefined){
a.bottom = {to: o.bottom};
}
if(x !== undefined || y !== undefined){
a.points = {to: [
x !== undefined ? x : this.getX(),
y !== undefined ? y : this.getY()
]};
}
if(op !== undefined){
a.opacity = {to: op};
}
if(o.xy !== undefined){
a.points = {to: o.xy};
}
arguments.callee.anim = this.fxanim(a,
o, 'motion', .35, "easeOut", function(){
el.afterFx(o);
});
});
return this;
},
/**
* Slides the element while fading it out of view. An anchor point can be optionally passed to set the
* ending point of the effect.
* Usage:
*<pre><code>
// default: slide the element downward while fading out
el.ghost();
// custom: slide the element out to the right with a 2-second duration
el.ghost('r', { duration: 2 });
// common config options shown with default values
el.ghost('b', {
easing: 'easeOut',
duration: .5,
remove: false,
useDisplay: false
});
</code></pre>
* @param {String} anchor (optional) One of the valid Fx anchor positions (defaults to bottom: 'b')
* @param {Object} options (optional) Object literal with any of the Fx config options
* @return {Ext.Element} The Element
*/
ghost : function(anchor, o){
var el = this.getFxEl();
o = o || {};
el.queueFx(o, function(){
anchor = anchor || "b";
// restore values after effect
var r = this.getFxRestore();
var w = this.getWidth(),
h = this.getHeight();
var st = this.dom.style;
var after = function(){
if(o.useDisplay){
el.setDisplayed(false);
}else{
el.hide();
}
el.clearOpacity();
el.setPositioning(r.pos);
st.width = r.width;
st.height = r.height;
el.afterFx(o);
};
var a = {opacity: {to: 0}, points: {}}, pt = a.points;
switch(anchor.toLowerCase()){
case "t":
pt.by = [0, -h];
break;
case "l":
pt.by = [-w, 0];
break;
case "r":
pt.by = [w, 0];
break;
case "b":
pt.by = [0, h];
break;
case "tl":
pt.by = [-w, -h];
break;
case "bl":
pt.by = [-w, h];
break;
case "br":
pt.by = [w, h];
break;
case "tr":
pt.by = [w, -h];
break;
}
arguments.callee.anim = this.fxanim(a,
o,
'motion',
.5,
"easeOut", after);
});
return this;
},
/**
* Ensures that all effects queued after syncFx is called on the element are
* run concurrently. This is the opposite of {@link #sequenceFx}.
* @return {Ext.Element} The Element
*/
syncFx : function(){
this.fxDefaults = Ext.apply(this.fxDefaults || {}, {
block : false,
concurrent : true,
stopFx : false
});
return this;
},
/**
* Ensures that all effects queued after sequenceFx is called on the element are
* run in sequence. This is the opposite of {@link #syncFx}.
* @return {Ext.Element} The Element
*/
sequenceFx : function(){
this.fxDefaults = Ext.apply(this.fxDefaults || {}, {
block : false,
concurrent : false,
stopFx : false
});
return this;
},
/* @private */
nextFx : function(){
var ef = this.fxQueue[0];
if(ef){
ef.call(this);
}
},
/**
* Returns true if the element has any effects actively running or queued, else returns false.
* @return {Boolean} True if element has active effects, else false
*/
hasActiveFx : function(){
return this.fxQueue && this.fxQueue[0];
},
/**
* Stops any running effects and clears the element's internal effects queue if it contains
* any additional effects that haven't started yet.
* @return {Ext.Element} The Element
*/
stopFx : function(){
if(this.hasActiveFx()){
var cur = this.fxQueue[0];
if(cur && cur.anim && cur.anim.isAnimated()){
this.fxQueue = [cur]; // clear out others
cur.anim.stop(true);
}
}
return this;
},
/* @private */
beforeFx : function(o){
if(this.hasActiveFx() && !o.concurrent){
if(o.stopFx){
this.stopFx();
return true;
}
return false;
}
return true;
},
/**
* Returns true if the element is currently blocking so that no other effect can be queued
* until this effect is finished, else returns false if blocking is not set. This is commonly
* used to ensure that an effect initiated by a user action runs to completion prior to the
* same effect being restarted (e.g., firing only one effect even if the user clicks several times).
* @return {Boolean} True if blocking, else false
*/
hasFxBlock : function(){
var q = this.fxQueue;
return q && q[0] && q[0].block;
},
/* @private */
queueFx : function(o, fn){
if(!this.fxQueue){
this.fxQueue = [];
}
if(!this.hasFxBlock()){
Ext.applyIf(o, this.fxDefaults);
if(!o.concurrent){
var run = this.beforeFx(o);
fn.block = o.block;
this.fxQueue.push(fn);
if(run){
this.nextFx();
}
}else{
fn.call(this);
}
}
return this;
},
/* @private */
fxWrap : function(pos, o, vis){
var wrap;
if(!o.wrap || !(wrap = Ext.get(o.wrap))){
var wrapXY;
if(o.fixPosition){
wrapXY = this.getXY();
}
var div = document.createElement("div");
div.style.visibility = vis;
wrap = Ext.get(this.dom.parentNode.insertBefore(div, this.dom));
wrap.setPositioning(pos);
if(wrap.getStyle("position") == "static"){
wrap.position("relative");
}
this.clearPositioning('auto');
wrap.clip();
wrap.dom.appendChild(this.dom);
if(wrapXY){
wrap.setXY(wrapXY);
}
}
return wrap;
},
/* @private */
fxUnwrap : function(wrap, pos, o){
this.clearPositioning();
this.setPositioning(pos);
if(!o.wrap){
wrap.dom.parentNode.insertBefore(this.dom, wrap.dom);
wrap.remove();
}
},
/* @private */
getFxRestore : function(){
var st = this.dom.style;
return {pos: this.getPositioning(), width: st.width, height : st.height};
},
/* @private */
afterFx : function(o){
if(o.afterStyle){
this.applyStyles(o.afterStyle);
}
if(o.afterCls){
this.addClass(o.afterCls);
}
if(o.remove === true){
this.remove();
}
Ext.callback(o.callback, o.scope, [this]);
if(!o.concurrent){
this.fxQueue.shift();
this.nextFx();
}
},
/* @private */
getFxEl : function(){ // support for composite element fx
return Ext.get(this.dom);
},
/* @private */
fxanim : function(args, opt, animType, defaultDur, defaultEase, cb){
animType = animType || 'run';
opt = opt || {};
var anim = Ext.lib.Anim[animType](
this.dom, args,
(opt.duration || defaultDur) || .35,
(opt.easing || defaultEase) || 'easeOut',
function(){
Ext.callback(cb, this);
},
this
);
opt.anim = anim;
return anim;
}
};
// backwords compat
Ext.Fx.resize = Ext.Fx.scale;
//When included, Ext.Fx is automatically applied to Element so that all basic
//effects are available directly via the Element API
Ext.apply(Ext.Element.prototype, Ext.Fx);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -