gpt4 book ai didi

javascript - ResizeObserver 是否最初在页面加载时调用?

转载 作者:行者123 更新时间:2023-12-03 07:06:23 26 4
gpt4 key购买 nike

似乎当我在 DOMContentLoaded 事件上将节点传递给 ResizeObserver.observe() 时,它会立即调用。它被认为是正常行为吗?

最佳答案

是的,此行为符合规范 (ref.):

  • Observation will fire when watched Element is inserted/removed from DOM.

  • Observation will fire when watched Element display gets set to none.

  • Observations do not fire for non-replaced inline Elements.

  • Observations will not be triggered by CSS transforms.

  • Observation will fire when observation starts if Element is being rendered, and Element’s size is not 0,0.



因此,在您的情况下,要么该元素尚未在 DOM 中,要么情况 1 将使其触发,要么已经存在,而情况 5 将(尽管在 DOMContentLoaded 中,应该是 5 ;)。

关于javascript - ResizeObserver 是否最初在页面加载时调用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60026223/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com