修复 H5 缩放等动画不播放:大厅 Web 首次显示补 onActive()
ArkWeb 文档:onInactive 态会暂停"可安全暂停的内容,例如动画"(CSS 动画/rAF),onActive 恢复。 本工程 controller.onActive() 原仅在从子游戏返回(activate)时调,**首次进大厅从未调用**, 大厅 Web 处于未激活态 → CSS transform/keyframes 动画与 requestAnimationFrame 被暂停, 表现为"画面在、但缩放等动画卡住不播放"。 修复:WebSlot 增 notifyShown()(调 controller.onActive(),幂等),在 setup() 激活槽建好即调, 并在 BridgeGameContainer 的 NavDestination.onShown 调用(首次进大厅 + 从通用网页返回均覆盖)。 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
5b9cfedb53
commit
d16c7259b4
@@ -254,6 +254,8 @@ export struct BridgeGameContainer {
|
||||
.width('100%').height('100%')
|
||||
}
|
||||
.hideTitleBar(true)
|
||||
// 页面(重新)可见时激活当前槽的 Web 引擎,恢复 CSS 动画/rAF(首次进大厅 + 从通用网页返回)
|
||||
.onShown(() => this.activeSlot()?.notifyShown())
|
||||
.onBackPressed(() => {
|
||||
// 分享面板打开时,返回键关闭面板并按取消回投(对齐 Android 点空白关闭)
|
||||
if (this.sharePanelVisible) {
|
||||
|
||||
@@ -74,6 +74,23 @@ export class WebSlot {
|
||||
} catch (e) {
|
||||
WebSlot.log.e(`[${this.role}] capability registration failed (bridge usable): ${(e as Error).message}`);
|
||||
}
|
||||
// 激活槽(大厅/子游戏)首次建好即通知 Web 引擎进入激活态——否则 ArkWeb 默认未激活态会
|
||||
// 暂停 CSS 动画/requestAnimationFrame(官方:onInactive 暂停动画),表现为"画面在但缩放等动画不播放"。
|
||||
if (this.active) {
|
||||
this.notifyShown();
|
||||
}
|
||||
}
|
||||
|
||||
/** 页面可见时确保 Web 引擎处于激活态,恢复 CSS 动画/rAF(与 NavDestination onShown 配合,幂等)。 */
|
||||
notifyShown(): void {
|
||||
if (this.disposed) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
this.controller.onActive();
|
||||
} catch (e) {
|
||||
WebSlot.log.w(`[${this.role}] onActive(notifyShown) failed: ${(e as BusinessError).message}`);
|
||||
}
|
||||
}
|
||||
|
||||
onLoadIntercept(url: string): boolean {
|
||||
|
||||
Reference in New Issue
Block a user