[animate] update

This commit is contained in:
2020-03-24 23:37:08 +03:00
parent 279baa1113
commit fe60e78b74
10 changed files with 73 additions and 54 deletions

View File

@@ -5,6 +5,7 @@ import flash.display.Sprite;
import hw.animate.Animate;
import hw.animate.IAnimate;
import hw.view.IView;
import promhx.Promise;
class CircleMaskAnimate extends Animate {
@@ -19,7 +20,7 @@ class CircleMaskAnimate extends Animate {
this.cyrcle = new Sprite();
}
override public function start(callback:IAnimate -> Void, custom:Bool = false):Void {
override public function start():Promise<IAnimate> {
var width = view.parent.width;
var height = view.parent.height;
size = Math.sqrt(width * width + height * height);
@@ -33,7 +34,7 @@ class CircleMaskAnimate extends Animate {
view.content.mask = mask;
view.parent.container.addChild(cyrcle);
super.start(callback, custom);
return super.start();
}
private function redraw(size:Float, r:Float):Void {
@@ -48,15 +49,14 @@ class CircleMaskAnimate extends Animate {
cyrcle.graphics.lineStyle();
}
override private function update(time:Float):Void {
super.update(time);
override public function update(time:Float):Bool {
var result = super.update(time);
redraw(size, size * progress);
if (progress >= 1 && view.content.parent != null) {
if (view.content.parent.contains(mask)) view.content.parent.removeChild(mask);
view.content.mask = null;
if (view.content.parent.contains(cyrcle)) view.parent.container.removeChild(cyrcle);
}
return result;
}
}