We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
目前通过 appendChild 将图形添加到画布时,首先会在子节点上触发 ElementEvent.INSERT,在画布根节点监听到后,会触发 MOUNTED 事件,该过程可以精简。
appendChild
ElementEvent.INSERT
MOUNTED
The text was updated successfully, but these errors were encountered:
暂时去掉 CHILD_INSERTED / REMOVED 事件,同时取消在 document 上对它们的监听。
CHILD_INSERTED / REMOVED
document
Sorry, something went wrong.
在首屏渲染阶段,每个图形都需要触发 MOUNTED 事件,如果还需要冒泡,将造成大量性能损耗。 一个可行的优化方式是 MOUNTED 事件仅在根节点出发,MOUNTED ATTR_MODIFIED 同理,这样可以省略事件传播的开销。
ATTR_MODIFIED
mountEvent.detail.target = child; this.context.renderingContext.root.dispatchEvent(mountEvent);
取消这些内置事件的冒泡过程,会导致 MutationObserver 不可用: https://g-next.antv.vision/zh/docs/api/builtin-objects/mutation-observer
因此需要在 DisplayObject 上新增一个状态,用于标识这些内置变更事件是否需要和交互事件一样进行传播:
DisplayObject
if (!child.isMutationObserved) { // skip event propagation mountedEvent.target = child; this.dispatchEvent(mountedEvent, true); } else { child.dispatchEvent(mountEvent); }
当使用 MutationObserver 开启监听时,设置 isMutationObserved 为 true:
isMutationObserved
true
// 创建一个 MutationObserver const observer = new MutationObserver(() => {}); // 开始监听 group1 上的变更 observer.observe(group1, { childList: true });
xiaoiver
No branches or pull requests
目前通过
appendChild
将图形添加到画布时,首先会在子节点上触发ElementEvent.INSERT
,在画布根节点监听到后,会触发MOUNTED
事件,该过程可以精简。The text was updated successfully, but these errors were encountered: