feat:should receive multi onRenderFinishedCallbacks

This commit is contained in:
pengfei.zhou
2020-03-10 19:18:33 +08:00
committed by osborn
parent f3f28c55f8
commit 1f5fd7de30
12 changed files with 104 additions and 40 deletions

View File

@@ -49,7 +49,7 @@ export function coordinator(context: BridgeContext) {
}) => {
if (context.entity instanceof Panel) {
const panel = context.entity
panel.onRenderFinished = () => {
panel.addOnRenderFinishedCallback(() => {
(argument as any).scrollable = viewIdChains(argument.scrollable)
if (argument.target instanceof View) {
(argument as any).target = viewIdChains(argument.target)
@@ -60,8 +60,8 @@ export function coordinator(context: BridgeContext) {
if (argument.changing.end instanceof Color) {
argument.changing.end = argument.changing.end.toModel()
}
return context.callNative("coordinator", "verticalScrolling", argument)
}
context.callNative("coordinator", "verticalScrolling", argument)
})
}
}
}

View File

@@ -45,7 +45,7 @@ export abstract class Panel {
private __root__ = new Root
private headviews: Map<string, Map<string, View>> = new Map
onRenderFinished?: () => void
private onRenderFinishedCallback: Array<() => void> = []
addHeadView(type: string, v: View) {
let map = this.headviews.get(type)
@@ -209,9 +209,17 @@ export abstract class Panel {
})
}
Promise.all(promises).then(_ => {
if (this.onRenderFinished) {
this.onRenderFinished()
}
this.onRenderFinished()
})
}
onRenderFinished() {
this.onRenderFinishedCallback.forEach(e => {
e()
})
this.onRenderFinishedCallback.length = 0
}
addOnRenderFinishedCallback(cb: () => void) {
this.onRenderFinishedCallback.push(cb)
}
}