1 goog.provide('lime.animation.Resize'); 2 3 4 goog.require('goog.math.Vec2'); 5 goog.require('lime.Sprite'); 6 goog.require('lime.animation.Animation'); 7 8 /** 9 * Resize element 10 * @constructor 11 * @param {goog.math.Size|number} size New element size. 12 * @param {number=} opt_height Optionaly use width,height as parameter 13 * @extends lime.animation.Animation 14 */ 15 lime.animation.Resize = function(size, opt_height) { 16 lime.animation.Animation.call(this); 17 18 if (arguments.length == 2) { 19 this.size_ = new goog.math.Size(arguments[0], arguments[1]); 20 } 21 else this.size_ = size; 22 23 24 }; 25 goog.inherits(lime.animation.Resize, lime.animation.Animation); 26 27 /** 28 * @inheritDoc 29 */ 30 lime.animation.Resize.prototype.scope = 'size'; 31 32 /** 33 * @inheritDoc 34 * @see lime.animation.Animation#makeTargetProp 35 */ 36 lime.animation.Resize.prototype.makeTargetProp = function(target) { 37 var size = target.getSize(), 38 delta = new goog.math.Vec2(this.size_.width - size.width, 39 this.size_.height - size.height); 40 41 return {startSize: size, 42 delta: delta}; 43 }; 44 45 /** 46 * @inheritDoc 47 * @see lime.animation.Animation#update 48 */ 49 lime.animation.Resize.prototype.update = function(t, target) { 50 if (this.status_ == 0) return; 51 var prop = this.getTargetProp(target); 52 53 target.setSize( 54 prop.startSize.width + prop.delta.x * t, 55 prop.startSize.height + prop.delta.y * t 56 ); 57 }; 58