replace NodeEventType.SIBLING_ORDER_CHANGED with NodeEventType.CHILDREN_ORDER_CHANGED (#16246)

* replace NodeEventType.SIBLING_ORDER_CHANGED with NodeEventType.CHILDREN_ORDER_CHANGED
This commit is contained in:
minggo
2023-09-13 14:06:43 +08:00
committed by GitHub
parent 0e53dde603
commit ea8ca11706
5 changed files with 16 additions and 8 deletions
+1 -1
View File
@@ -265,7 +265,7 @@ export enum SystemEventType {
* @en The event type for node's sibling order changed.
* @zh 当节点在兄弟节点中的顺序发生变化时触发的事件。
*
* @deprecated since v3.3, please use Node.EventType.SIBLING_ORDER_CHANGED instead
* @deprecated since v3.3, please use Node.EventType.CHILDREN_ORDER_CHANGED instead
*/
SIBLING_ORDER_CHANGED = 'sibling-order-changed',
}
+10 -2
View File
@@ -245,11 +245,19 @@ export enum NodeEventType {
LAYER_CHANGED = 'layer-changed',
/**
* @en The event type for node's sibling order changed.
* @zh 当节点在兄弟节点中的顺序发生变化时触发的事件。
* @en This event indicates that the order of child nodes has been changed.
* @zh 该事件表示子节点的排序发生了改变。
* @deprecated since v3.8.2 @en Please use `CHILDREN_ORDER_CHANGED`. @zh 请使用 `CHILDREN_ORDER_CHANGED`。
*/
SIBLING_ORDER_CHANGED = 'sibling-order-changed',
/**
* @en This event indicates that the order of child nodes has been changed.
* @zh 该事件表示子节点的排序发生了改变。
*/
// eslint-disable-next-line @typescript-eslint/no-duplicate-enum-values
CHILDREN_ORDER_CHANGED = 'sibling-order-changed',
/**
* @en
* Note: This event is only emitted from the top most node whose active value did changed,
+2 -2
View File
@@ -280,7 +280,7 @@ nodeProto.on = function (type, callback, target, useCapture: any = false) {
this._registeredNodeEventTypeMask |= REGISTERED_EVENT_MASK_LAYER_CHANGED;
}
break;
case NodeEventType.SIBLING_ORDER_CHANGED:
case NodeEventType.CHILDREN_ORDER_CHANGED:
if (!(this._registeredNodeEventTypeMask & REGISTERED_EVENT_MASK_SIBLING_ORDER_CHANGED)) {
this._registerOnSiblingOrderChanged();
this._registeredNodeEventTypeMask |= REGISTERED_EVENT_MASK_SIBLING_ORDER_CHANGED;
@@ -492,7 +492,7 @@ nodeProto.destroyAllChildren = function destroyAllChildren() {
};
nodeProto._onSiblingOrderChanged = function () {
this.emit(NodeEventType.SIBLING_ORDER_CHANGED);
this.emit(NodeEventType.CHILDREN_ORDER_CHANGED);
};
nodeProto._onActivateNode = function (shouldActiveNow) {
+1 -1
View File
@@ -1309,7 +1309,7 @@ export class Node extends CCObject implements ISchedulable, CustomSerializable {
this._children[i]._siblingIndex = i;
}
this.emit(NodeEventType.SIBLING_ORDER_CHANGED);
this.emit(NodeEventType.CHILDREN_ORDER_CHANGED);
}
protected _instantiate (cloned, isSyncedNode): any {
+2 -2
View File
@@ -736,7 +736,7 @@ export class Layout extends Component {
this.node.on(NodeEventType.ANCHOR_CHANGED, this._doLayoutDirty, this);
this.node.on(NodeEventType.CHILD_ADDED, this._childAdded, this);
this.node.on(NodeEventType.CHILD_REMOVED, this._childRemoved, this);
this.node.on(NodeEventType.SIBLING_ORDER_CHANGED, this._childrenChanged, this);
this.node.on(NodeEventType.CHILDREN_ORDER_CHANGED, this._childrenChanged, this);
this.node.on('childrenSiblingOrderChanged', this.updateLayout, this);
this._addChildrenEventListeners();
}
@@ -747,7 +747,7 @@ export class Layout extends Component {
this.node.off(NodeEventType.ANCHOR_CHANGED, this._doLayoutDirty, this);
this.node.off(NodeEventType.CHILD_ADDED, this._childAdded, this);
this.node.off(NodeEventType.CHILD_REMOVED, this._childRemoved, this);
this.node.off(NodeEventType.SIBLING_ORDER_CHANGED, this._childrenChanged, this);
this.node.off(NodeEventType.CHILDREN_ORDER_CHANGED, this._childrenChanged, this);
this.node.off('childrenSiblingOrderChanged', this.updateLayout, this);
this._removeChildrenEventListeners();
}