📄 fx.js
字号:
* 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>// defaultel.switchOff();// all config options shown with default valuesel.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 yellowel.highlight();// custom: highlight foreground text to blue for 2 secondsel.highlight("0000ff", { attr: 'color', duration: 2 });// common config options shown with default valuesel.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 rippleel.frame();// custom: 3 red ripples lasting 3 seconds totalel.frame("ff0000", 3, { duration: 3 });// common config options shown with default valuesel.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(), proxy, active; o = o || {}; el.queueFx(o, function(){ color = color || "#C3DAF9" if(color.length == 6){ color = "#" + color; } count = count || 1; this.show(); var xy = this.getXY(), dom = this.dom, b = {x: xy[0], y: xy[1], 0: xy[0], 1: xy[1], width: dom.offsetWidth, height: dom.offsetHeight}, proxy, queue = function(){ proxy = Ext.get(document.body || document.documentElement).createChild({ style:{ visbility: 'hidden', position : 'absolute', "z-index": 35000, // yee haw border : "0px solid " + color } }); return proxy.queueFx({}, animFn); }; arguments.callee.anim = { isAnimated: function(){ return true; }, stop: function() { count = 0; proxy.stopFx(); } }; function animFn(){ var scale = Ext.isBorderBox ? 2 : 1; active = proxy.anim({ 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: o.duration || 1, callback: function() { proxy.remove(); --count > 0 ? queue() : el.afterFx(o); } }); arguments.callee.anim = { isAnimated: function(){ return true; }, stop: function(){ active.stop(); } }; }; queue(); }); 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(), t; el.queueFx({}, function(){ t = setTimeout(function(){ el.afterFx({}); }, seconds * 1000); arguments.callee.anim = { isAnimated: function(){ return true; }, stop: function(){ clearTimeout(t); el.afterFx({}); } }; }); 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 secondsel.fadeIn({ endOpacity: .75, duration: 2});// common config options shown with default valuesel.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 0el.fadeOut();// custom: fade out from the element's current opacity to 25% over 2 secondsel.fadeOut({ endOpacity: .25, duration: 2});// common config options shown with default valuesel.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 pixelsel.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; },
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -