Skip to content

Commit

Permalink
Merge branch 'release/1.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
Sunjammer committed Jan 21, 2015
2 parents c88c770 + c923785 commit 53d3b87
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions tween/Delta.hx
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ private class TweenAction {
var totalDuration:Float;
var prevPropCreated:Null<PropertyTween>;
var onCompleteFunc:Null < Void->Void > ;
var onStepFunc:Null < Float->Void > ;
var triggeringID:Null<String>;
var triggerID:Null<String>;
var triggerOnComplete:Bool;
Expand All @@ -100,6 +101,11 @@ private class TweenAction {
}
}

public inline function onUpdate(func:Float->Void):TweenAction {
onStepFunc = func;
return this;
}

public inline function onComplete(func:Void->Void):TweenAction {
onCompleteFunc = func;
return this;
Expand Down Expand Up @@ -149,10 +155,6 @@ private class TweenAction {
public function prop(property:String, value:Float, duration:Float):TweenAction {

if(properties==null) properties = new Map<String,PropertyTween>();
#if debug
if (!Reflect.hasField(target, property)) throw 'No property "$property" on object';
//TODO: Check if the field is a property or not and if so, warn
#end
totalDuration = Math.max(totalDuration, duration);
properties.set(property, prevPropCreated = new PropertyTween(this, property, value, duration));
return this;
Expand Down Expand Up @@ -218,6 +220,9 @@ private class TweenAction {
if (time >= totalDuration) {
finish();
}
if (onStepFunc != null) {
onStepFunc(time / totalDuration);
}
return this;
}
}
Expand Down Expand Up @@ -306,6 +311,7 @@ class Delta
}

public static function tween(target:Dynamic):TweenAction {
if (target == null) throw "Cannot tween null target";
return createSequence(target).createAction();
}

Expand Down

0 comments on commit 53d3b87

Please sign in to comment.