Created
March 5, 2013 01:33
-
-
Save lb1064/5087306 to your computer and use it in GitHub Desktop.
ff
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * 动画 | |
| * @public | |
| * @class Atom.animation.Actor | |
| * @description 混合类型,凡是拥有Atom.animation.Actor混合类型的类都有使用动画的能力 | |
| */ | |
| Atom.define('Atom.animation.Actor', { | |
| initConfig : function(){ | |
| this._action = this._action || {}; | |
| this._original = this._original || {}; | |
| this._history = this._history || []; | |
| }, | |
| getActionTypes : function(){ | |
| this.initConfig.call(this); | |
| var types = []; | |
| for(var type in this._action){ | |
| if(type != 'callback'){ | |
| types.push(type); | |
| } | |
| } | |
| return types; | |
| }, | |
| getAction : function(type){ | |
| this.initConfig.call(this); | |
| return this._action[type]; | |
| }, | |
| setAction : function(type, value, record){ | |
| this.initConfig.call(this); | |
| this._action[type] = value; | |
| if(record){ | |
| var typeValue = this.get(type); | |
| if(type == 'style.opacity'&&Atom.isEmpty(typeValue)){ | |
| typeValue = 1; | |
| } | |
| this._original[type] = typeValue; | |
| } | |
| }, | |
| setOriginal : function(type, value){ | |
| this.initConfig.call(this); | |
| this._original[type] = value; | |
| }, | |
| clearAction : function(){ | |
| this._action = {}; | |
| }, | |
| reaction : function(){ | |
| this.initConfig.call(this); | |
| var _history = this._history; | |
| var me = this; | |
| if(_history && _history.length > 0){ | |
| me._original = _history.pop(); | |
| if(me._original){ | |
| me._action = me._original; | |
| } | |
| }else{ | |
| me._action = me._original; | |
| me._original = _history.pop() || {}; | |
| } | |
| }, | |
| newaction : function(){ | |
| this.initConfig.call(this); | |
| this._history.push(this._original); | |
| this._original = {}; | |
| }, | |
| getDom : function(){ | |
| throw "未覆盖此方法:getDom()"; | |
| }, | |
| setActorStyle : function(name, value){ | |
| this.initConfig.call(this); | |
| if(!this.getDom()){ | |
| return; | |
| } | |
| if(Atom.isFunction(this.withActor)){ | |
| this.set(name,value); | |
| this.withActor.call(this); | |
| } | |
| var tmpName = name.replace('style.',''); | |
| if(tmpName != 'opacity'){ | |
| value = Math.round(value); | |
| }else{ | |
| this.getDom().style.filter = "alpha(opacity=" + (value * 100).toFixed() +")"; | |
| } | |
| if(tmpName == 'opacity' || tmpName == 'zIndex'){ | |
| this.getDom().style[tmpName] = value; | |
| }else{ | |
| if((tmpName=='width'||tmpName=='height')&&value < 0){ | |
| value = 0; | |
| } | |
| this.getDom().style[tmpName] = value + 'px'; | |
| } | |
| } | |
| }); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment