feat:change animator api

This commit is contained in:
pengfei.zhou 2019-12-14 11:31:19 +08:00
parent fb47613b89
commit 75fe22290a
2 changed files with 38 additions and 26 deletions

View File

@ -15,11 +15,15 @@
*/ */
import { Panel } from "../ui/panel" import { Panel } from "../ui/panel"
import { takeLet } from "../pattern/candies" import { takeLet } from "../pattern/candies"
import { BridgeContext } from "../runtime/global"
/** /**
* Only supports x,y,width,height,corner(just for four corners),rotation,bgColor, * Only supports x,y,width,height,corner(just for four corners),rotation,bgColor,
* @param panel @see Panel * @param panel @see Panel
*/ */
export function animate(panel: Panel) { export function animate(context: BridgeContext) {
const entity = context.entity
if (entity instanceof Panel) {
let panel = entity
return (args: { return (args: {
animations: () => void, animations: () => void,
duration: number, duration: number,
@ -48,4 +52,13 @@ export function animate(panel: Panel) {
}) })
}) as Promise<any> }) as Promise<any>
} }
} else {
return (args: {
animations: () => void,
duration: number,
}) => {
return Promise.reject(`Cannot find panel in Context:${context.id}`)
}
}
} }

View File

@ -1,5 +1,3 @@
import { Modeling, Model } from "../util/types"
/* /*
* Copyright [2019] [Doric.Pub] * Copyright [2019] [Doric.Pub]
* *
@ -16,6 +14,7 @@ import { Modeling, Model } from "../util/types"
* limitations under the License. * limitations under the License.
*/ */
import { Modeling, Model } from "../util/types"
export type AnimatedKey = "translationX" | "translationY" | "scaleX" | "scaleY" | "rotation" | "pivotX" | "pivotY" export type AnimatedKey = "translationX" | "translationY" | "scaleX" | "scaleY" | "rotation" | "pivotX" | "pivotY"