Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

optimize reordering event code to fix problems with setting zIndex #4060

Merged
merged 1 commit into from Mar 27, 2019

Conversation

Projects
None yet
3 participants
@knoxHuang
Copy link
Collaborator

commented Mar 18, 2019

Re: cocos-creator/2d-tasks#1186

Changes:

  • 优化对平级节点的 zIndex 刷新操作

优化前:

image

优化后:

image

@knoxHuang knoxHuang self-assigned this Mar 18, 2019

@knoxHuang knoxHuang requested a review from pandamicro Mar 18, 2019

@@ -3011,6 +3010,10 @@ var Node = cc.Class({
*/
sortAllChildren () {
if (this._reorderChildDirty) {
// Optimize reordering event code to fix problems with setting zindex
// https://github.com/cocos-creator/2d-tasks/issues/1186
eventManager._setDirtyForNode(this);

This comment has been minimized.

Copy link
@jareguo

jareguo Mar 19, 2019

Contributor

@pandamicro 确认下这边的逻辑,之前是对子节点调用 N 次 _setDirtyForNode,现在是只要有一个子节点修改过 zIndex,就对父节点调用一次 _setDirtyForNode

This comment has been minimized.

Copy link
@pandamicro

pandamicro Mar 26, 2019

Member

这是个临时解决方案,根本问题是 EventManager 中对 priority 的排序逻辑非常复杂,其实应该在 renderer visit tree 的时候记录下来 node 优先级顺序,然后在 EventManager 中直接使用这个顺序进行排序, 可以省掉非常多逻辑,对于事件系统也有优化,我记录在另一个 issue 里面

This comment has been minimized.

@pandamicro

This comment has been minimized.

Copy link
Member

commented Mar 26, 2019

如果这个问题很严重,那么 PR 作为临时方案可以合并 @jareguo

@pandamicro pandamicro merged commit 2494599 into cocos-creator:v2.0-release Mar 27, 2019

1 check passed

ci/circleci: test Your tests passed on CircleCI!
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.