1 goog.provide('lime.animation.FadeTo');
  2 
  3 
  4 goog.require('lime.Sprite');
  5 goog.require('lime.animation.Animation');
  6 
  7 /**
  8  * Animation for changing elements opacity value
  9  * @constructor
 10  * @param {number} opacity New opacity value.
 11  * @extends lime.animation.Animation
 12  */
 13 lime.animation.FadeTo = function(opacity) {
 14     lime.animation.Animation.call(this);
 15 
 16     this.opacity_ = opacity;
 17 
 18 };
 19 goog.inherits(lime.animation.FadeTo, lime.animation.Animation);
 20 
 21 /**
 22  * @inheritDoc
 23  */
 24 lime.animation.FadeTo.prototype.scope = 'fade';
 25 
 26 /**
 27  * @inheritDoc
 28  * @see lime.animation.Animation#makeTargetProp
 29  */
 30 lime.animation.FadeTo.prototype.makeTargetProp = function(target) {
 31     var op = target.getOpacity();
 32     if (this.useTransitions()) {
 33         target.addTransition(lime.Transition.OPACITY,
 34             this.opacity_,
 35             this.duration_, this.getEasing());
 36 
 37         target.setDirty(lime.Dirty.ALPHA);
 38     }
 39     return {startOpacity: op, delta: this.opacity_ - op };
 40 };
 41 
 42 /**
 43  * @inheritDoc
 44  * @see lime.animation.Animation#update
 45  */
 46 lime.animation.FadeTo.prototype.update = function(t, target) {
 47     if (this.status_ == 0) return;
 48     var prop = this.getTargetProp(target);
 49 
 50     target.setOpacity(prop.startOpacity + prop.delta * t);
 51 
 52 };
 53 
 54 /**
 55  * @inheritDoc
 56  * @see lime.animation.Animation#clearTransition
 57  */
 58 lime.animation.FadeTo.prototype.clearTransition = function(target) {
 59     if (this.useTransitions()) {
 60         target.clearTransition(lime.Transition.OPACITY);
 61         target.setDirty(lime.Dirty.ALPHA);
 62     }
 63 };
 64 
 65