/**
 * Created by JetBrains PhpStorm.
 * User: Administrator
 * Date: 13-6-13
 * Time: 上午2:04
 *
 */

goog.provide("bok.util.EaselAnimationHelper");
goog.require("org.createjs.easeljs.EaselJS");
goog.require("org.createjs.tweenjs.TweenJS");

function EaselAnimationHelper()
{

}

/**
 * @param object
 * @param {number} x
 * @param {number} y
 * @param {number} duration In ms
 * @return {createjs.Tween}
 * */
EaselAnimationHelper.bounceTo = function(object, x, y, duration)
{
	return createjs.Tween.get(object).to({x:x, y:y}, duration, createjs.Ease.bounceOut);
};

/**
 * @param object
 * @param {number} x
 * @param {number} y
 * @param {number} duration In ms
 * @param {Function=} easeFunc should be one of {createjs.Ease}
 * @return {createjs.Tween}
 * */
EaselAnimationHelper.moveTo = function(object, x, y, duration, easeFunc)
{
	return createjs.Tween.get(object).to({x:x, y:y}, duration, easeFunc ? easeFunc : createjs.Ease.cubicOut);
};

/**
 * @param object
 * @param {number} distance
 * @param {number} duration In ms
 * @param {number=} delay (option) In ms
 * @return {createjs.Tween}
 * */
EaselAnimationHelper.standOut = function(object, distance, duration, delay)
{
	if(!object.shadow)
		object.shadow = new createjs.Shadow("#000000", 0, 0, 0);

	createjs.Tween.get(object).wait(delay).to({x:object.x-distance, y:object.y-distance}, duration, createjs.Ease.cubicOut);
	return createjs.Tween.get(object.shadow).wait(delay).to({offsetX:distance, offsetY:distance, blur:10}, duration, createjs.Ease.cubicOut);
};

EaselAnimationHelper.putDown = function(object, duration)
{
	createjs.Tween.get(object).to({x:object.x+object.shadow.offsetX, y:object.y+object.shadow.offsetY}, duration, createjs.Ease.cubicOut);
	return createjs.Tween.get(object.shadow).to({offsetX:0, offsetY:0, blur:0}, duration, createjs.Ease.cubicOut);
};

EaselAnimationHelper.disappear = function(object, duration)
{
	return createjs.Tween.get(object).to({alpha:0}, duration || 700, createjs.Ease.cubicOut);
};

EaselAnimationHelper.fadeIn = function(object, duration)
{
    object.alpha = 0;
	return createjs.Tween.get(object).to({alpha:1}, duration || 700, createjs.Ease.cubicIn);
};


@@ -1885,32 +1885,39 @@
 object, duration
+, delay
 )%0A%7B%0A%09return crea
@@ -1931,32 +1931,44 @@
 een.get(object).
+wait(delay).
 to(%7Balpha:0%7D, du
@@ -2062,24 +2062,31 @@
 ct, duration
+, delay
 )%0A%7B%0A    obje
@@ -2130,24 +2130,36 @@
 get(object).
+wait(delay).
 to(%7Balpha:1%7D

add delay to animation helper