feat:add animator
This commit is contained in:
@@ -1,3 +1,8 @@
|
||||
import { Panel } from "./panel"
|
||||
import { takeLet } from "../pattern/candies"
|
||||
import { O_TRUNC } from "constants"
|
||||
import { modal } from "../native/modal"
|
||||
|
||||
/*
|
||||
* Copyright [2019] [Doric.Pub]
|
||||
*
|
||||
@@ -151,4 +156,39 @@ export class AnimationSet {
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
export function animator(panel: Panel) {
|
||||
return (args: {
|
||||
animations: () => void,
|
||||
duration: number,
|
||||
complete?: () => void
|
||||
}) => {
|
||||
takeLet(panel.context.shader)(it => {
|
||||
it.animator().then(() => {
|
||||
args.animations()
|
||||
return takeLet(panel.getRootView())(root => {
|
||||
if (root.isDirty()) {
|
||||
const model = root.toModel();
|
||||
(model as any).duration = args.duration
|
||||
const ret = it.animateRender(model)
|
||||
root.clean()
|
||||
return ret
|
||||
}
|
||||
for (let v of panel.allHeadViews()) {
|
||||
if (v.isDirty()) {
|
||||
const model = v.toModel()
|
||||
const ret = it.animateRender(model)
|
||||
it.clean()
|
||||
return ret
|
||||
}
|
||||
}
|
||||
})
|
||||
}).then(() => {
|
||||
if (args.complete) {
|
||||
args.complete()
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
@@ -49,7 +49,9 @@ export abstract class Panel {
|
||||
addHeadView(v: View) {
|
||||
this.headviews.set(v.viewId, v)
|
||||
}
|
||||
|
||||
allHeadViews() {
|
||||
return this.headviews.values()
|
||||
}
|
||||
removeHeadView(v: View | string) {
|
||||
if (v instanceof View) {
|
||||
this.headviews.delete(v.viewId)
|
||||
|
Reference in New Issue
Block a user