From ed7e071a01b8090d15c32ff09152b32f192f4335 Mon Sep 17 00:00:00 2001 From: "pengfei.zhou" Date: Fri, 29 Nov 2019 13:10:00 +0800 Subject: [PATCH] feat:add Color.alpha --- demo/src/AnimatorDemo.ts | 10 ++++++++-- js-framework/src/util/color.ts | 4 ++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/demo/src/AnimatorDemo.ts b/demo/src/AnimatorDemo.ts index b5a12243..9a7c7572 100644 --- a/demo/src/AnimatorDemo.ts +++ b/demo/src/AnimatorDemo.ts @@ -21,6 +21,9 @@ class AnimatorDemo extends Panel { view.width = view.height = 20 }, duration: 3000, + complete: () => { + modal(context).toast('Fininshed') + }, }) } }), @@ -35,9 +38,12 @@ class AnimatorDemo extends Panel { v.onClick = () => { animator(this)({ animations: () => { - view.width = 500 + view.width = 300 }, duration: 3000, + complete: () => { + modal(context).toast('Fininshed') + }, }) } }), @@ -67,7 +73,7 @@ class AnimatorDemo extends Panel { }) ]).apply({ layoutConfig: layoutConfig().atmost(), - bgColor: colors[3], + bgColor: colors[1].alpha(0.3 * 255), }), ]).apply({ layoutConfig: layoutConfig().atmost().h(LayoutSpec.WRAP_CONTENT), diff --git a/js-framework/src/util/color.ts b/js-framework/src/util/color.ts index a703fa9a..bac1f9c3 100644 --- a/js-framework/src/util/color.ts +++ b/js-framework/src/util/color.ts @@ -62,6 +62,10 @@ export class Color implements Modeling { } } + alpha(v: number) { + return new Color((this._value & 0xffffff) | ((v & 0xff) << 24)) + } + toModel() { return this._value }