keytops-game-framework 1.0.25 → 1.0.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +23 -1
- package/dist/view/View.d.ts +4 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -7643,11 +7643,33 @@ let View = View_1 = class View extends cc.Component {
|
|
|
7643
7643
|
addView(view, index) {
|
|
7644
7644
|
view.setControl(this._control);
|
|
7645
7645
|
view.node.parent = this.node;
|
|
7646
|
-
(view.node.getComponent(cc.UITransform) || view.node.addComponent(cc.UITransform)).priority = index;
|
|
7646
|
+
(view.node.getComponent(cc.UITransform) || view.node.addComponent(cc.UITransform)).priority = index !== null && index !== void 0 ? index : 0;
|
|
7647
|
+
this._sortChildrenByViewPriority();
|
|
7647
7648
|
viewManager.event("open", view);
|
|
7648
7649
|
viewManager.reportViewAnalytics("open", view);
|
|
7649
7650
|
analytics.session.updateSessionDuration();
|
|
7650
7651
|
}
|
|
7652
|
+
/**
|
|
7653
|
+
* 兼容 UITransform.priority 的旧层级语义,避免不同平台延迟排序导致同级 View 渲染顺序不稳定。
|
|
7654
|
+
*/
|
|
7655
|
+
_sortChildrenByViewPriority() {
|
|
7656
|
+
const sortedChildren = this.node.children.map((child, originalSiblingIndex) => {
|
|
7657
|
+
var _a, _b;
|
|
7658
|
+
return {
|
|
7659
|
+
child,
|
|
7660
|
+
originalSiblingIndex,
|
|
7661
|
+
priority: (_b = (_a = child.getComponent(cc.UITransform)) === null || _a === void 0 ? void 0 : _a.priority) !== null && _b !== void 0 ? _b : 0,
|
|
7662
|
+
};
|
|
7663
|
+
}).sort((a, b) => {
|
|
7664
|
+
if (a.priority !== b.priority) {
|
|
7665
|
+
return a.priority - b.priority;
|
|
7666
|
+
}
|
|
7667
|
+
return a.originalSiblingIndex - b.originalSiblingIndex;
|
|
7668
|
+
});
|
|
7669
|
+
sortedChildren.forEach(({ child }, sortedIndex) => {
|
|
7670
|
+
child.setSiblingIndex(sortedIndex);
|
|
7671
|
+
});
|
|
7672
|
+
}
|
|
7651
7673
|
/**
|
|
7652
7674
|
* 移除子视图
|
|
7653
7675
|
* @param view 子视图
|
package/dist/view/View.d.ts
CHANGED
|
@@ -62,6 +62,10 @@ export declare class View extends cc.Component implements IView {
|
|
|
62
62
|
* @param index 视图索引
|
|
63
63
|
*/
|
|
64
64
|
addView(view: View, index?: number): void;
|
|
65
|
+
/**
|
|
66
|
+
* 兼容 UITransform.priority 的旧层级语义,避免不同平台延迟排序导致同级 View 渲染顺序不稳定。
|
|
67
|
+
*/
|
|
68
|
+
private _sortChildrenByViewPriority;
|
|
65
69
|
/**
|
|
66
70
|
* 移除子视图
|
|
67
71
|
* @param view 子视图
|