📄 fx.js
字号:
opacity : {to: 0},
fontSize: {to:200, unit: "%"}
},
o,
'motion',
.5,
"easeOut", after);
});
return this;
},
/**
* Blinks the element as if it was clicked and then collapses on its center (similar to switching off a television).
* When the effect is completed, the element will be hidden (visibility = 'hidden') but block elements will still
* take up space in the document. The element must be removed from the DOM using the 'remove' config option if desired.
* Usage:
*<pre><code>
// default
el.switchOff();
// all config options shown with default values
el.switchOff({
easing: 'easeIn',
duration: .3,
remove: false,
useDisplay: false
});
</code></pre>
* @param {Object} options (optional) Object literal with any of the Fx config options
* @return {Ext.Element} The Element
*/
switchOff : function(o){
var el = this.getFxEl();
o = o || {};
el.queueFx(o, function(){
this.clearOpacity();
this.clip();
// restore values after effect
var r = this.getFxRestore();
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);
};
this.fxanim({opacity:{to:0.3}}, null, null, .1, null, function(){
this.clearOpacity();
(function(){
this.fxanim({
height:{to:1},
points:{by:[0, this.getHeight() * .5]}
}, o, 'motion', 0.3, 'easeIn', after);
}).defer(100, this);
});
});
return this;
},
/**
* Highlights the Element by setting a color (applies to the background-color by default, but can be
* changed using the "attr" config option) and then fading back to the original color. If no original
* color is available, you should provide the "endColor" config option which will be cleared after the animation.
* Usage:
<pre><code>
// default: highlight background to yellow
el.highlight();
// custom: highlight foreground text to blue for 2 seconds
el.highlight("0000ff", { attr: 'color', duration: 2 });
// common config options shown with default values
el.highlight("ffff9c", {
attr: "background-color", //can be any valid CSS property (attribute) that supports a color value
endColor: (current color) or "ffffff",
easing: 'easeIn',
duration: 1
});
</code></pre>
* @param {String} color (optional) The highlight color. Should be a 6 char hex color without the leading # (defaults to yellow: 'ffff9c')
* @param {Object} options (optional) Object literal with any of the Fx config options
* @return {Ext.Element} The Element
*/
highlight : function(color, o){
var el = this.getFxEl();
o = o || {};
el.queueFx(o, function(){
color = color || "ffff9c";
var attr = o.attr || "backgroundColor";
this.clearOpacity();
this.show();
var origColor = this.getColor(attr);
var restoreColor = this.dom.style[attr];
var endColor = (o.endColor || origColor) || "ffffff";
var after = function(){
el.dom.style[attr] = restoreColor;
el.afterFx(o);
};
var a = {};
a[attr] = {from: color, to: endColor};
arguments.callee.anim = this.fxanim(a,
o,
'color',
1,
'easeIn', after);
});
return this;
},
/**
* Shows a ripple of exploding, attenuating borders to draw attention to an Element.
* Usage:
<pre><code>
// default: a single light blue ripple
el.frame();
// custom: 3 red ripples lasting 3 seconds total
el.frame("ff0000", 3, { duration: 3 });
// common config options shown with default values
el.frame("C3DAF9", 1, {
duration: 1 //duration of each individual ripple.
// Note: Easing is not configurable and will be ignored if included
});
</code></pre>
* @param {String} color (optional) The color of the border. Should be a 6 char hex color without the leading # (defaults to light blue: 'C3DAF9').
* @param {Number} count (optional) The number of ripples to display (defaults to 1)
* @param {Object} options (optional) Object literal with any of the Fx config options
* @return {Ext.Element} The Element
*/
frame : function(color, count, o){
var el = this.getFxEl();
o = o || {};
el.queueFx(o, function(){
color = color || "#C3DAF9";
if(color.length == 6){
color = "#" + color;
}
count = count || 1;
var duration = o.duration || 1;
this.show();
var b = this.getBox();
var animFn = function(){
var proxy = Ext.getBody().createChild({
style:{
visbility:"hidden",
position:"absolute",
"z-index":"35000", // yee haw
border:"0px solid " + color
}
});
var scale = Ext.isBorderBox ? 2 : 1;
proxy.animate({
top:{from:b.y, to:b.y - 20},
left:{from:b.x, to:b.x - 20},
borderWidth:{from:0, to:10},
opacity:{from:1, to:0},
height:{from:b.height, to:(b.height + (20*scale))},
width:{from:b.width, to:(b.width + (20*scale))}
}, duration, function(){
proxy.remove();
if(--count > 0){
animFn();
}else{
el.afterFx(o);
}
});
};
animFn.call(this);
});
return this;
},
/**
* Creates a pause before any subsequent queued effects begin. If there are
* no effects queued after the pause it will have no effect.
* Usage:
<pre><code>
el.pause(1);
</code></pre>
* @param {Number} seconds The length of time to pause (in seconds)
* @return {Ext.Element} The Element
*/
pause : function(seconds){
var el = this.getFxEl();
var o = {};
el.queueFx(o, function(){
setTimeout(function(){
el.afterFx(o);
}, seconds * 1000);
});
return this;
},
/**
* Fade an element in (from transparent to opaque). The ending opacity can be specified
* using the "endOpacity" config option.
* Usage:
<pre><code>
// default: fade in from opacity 0 to 100%
el.fadeIn();
// custom: fade in from opacity 0 to 75% over 2 seconds
el.fadeIn({ endOpacity: .75, duration: 2});
// common config options shown with default values
el.fadeIn({
endOpacity: 1, //can be any value between 0 and 1 (e.g. .5)
easing: 'easeOut',
duration: .5
});
</code></pre>
* @param {Object} options (optional) Object literal with any of the Fx config options
* @return {Ext.Element} The Element
*/
fadeIn : function(o){
var el = this.getFxEl();
o = o || {};
el.queueFx(o, function(){
this.setOpacity(0);
this.fixDisplay();
this.dom.style.visibility = 'visible';
var to = o.endOpacity || 1;
arguments.callee.anim = this.fxanim({opacity:{to:to}},
o, null, .5, "easeOut", function(){
if(to == 1){
this.clearOpacity();
}
el.afterFx(o);
});
});
return this;
},
/**
* Fade an element out (from opaque to transparent). The ending opacity can be specified
* using the "endOpacity" config option. Note that IE may require useDisplay:true in order
* to redisplay correctly.
* Usage:
<pre><code>
// default: fade out from the element's current opacity to 0
el.fadeOut();
// custom: fade out from the element's current opacity to 25% over 2 seconds
el.fadeOut({ endOpacity: .25, duration: 2});
// common config options shown with default values
el.fadeOut({
endOpacity: 0, //can be any value between 0 and 1 (e.g. .5)
easing: 'easeOut',
duration: .5,
remove: false,
useDisplay: false
});
</code></pre>
* @param {Object} options (optional) Object literal with any of the Fx config options
* @return {Ext.Element} The Element
*/
fadeOut : function(o){
var el = this.getFxEl();
o = o || {};
el.queueFx(o, function(){
var to = o.endOpacity || 0;
arguments.callee.anim = this.fxanim({opacity:{to:to}},
o, null, .5, "easeOut", function(){
if(to === 0){
if(this.visibilityMode == Ext.Element.DISPLAY || o.useDisplay){
this.dom.style.display = "none";
}else{
this.dom.style.visibility = "hidden";
}
this.clearOpacity();
}
el.afterFx(o);
});
});
return this;
},
/**
* Animates the transition of an element's dimensions from a starting height/width
* to an ending height/width.
* Usage:
<pre><code>
// change height and width to 100x100 pixels
el.scale(100, 100);
// common config options shown with default values. The height and width will default to
// the element's existing values if passed as null.
el.scale(
[element's width],
[element's height], {
easing: 'easeOut',
duration: .35
}
);
</code></pre>
* @param {Number} width The new width (pass undefined to keep the original width)
* @param {Number} height The new height (pass undefined to keep the original height)
* @param {Object} options (optional) Object literal with any of the Fx config options
* @return {Ext.Element} The Element
*/
scale : function(w, h, o){
this.shift(Ext.apply({}, o, {
width: w,
height: h
}));
return this;
},
/**
* Animates the transition of any combination of an element's dimensions, xy position and/or opacity.
* Any of these properties not specified in the config object will not be changed. This effect
* requires that at least one new dimension, position or opacity setting must be passed in on
* the config object in order for the function to have any effect.
* Usage:
<pre><code>
// slide the element horizontally to x position 200 while changing the height and opacity
el.shift({ x: 200, height: 50, opacity: .8 });
// common config options shown with default values.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -