How to detect resize of any element in HTML5

后端 未结 4 785
时光取名叫无心
时光取名叫无心 2021-02-13 12:05

What should the best practices to listen on element resize event?

I want to re-position an element (jQuery dialog in my case), once it\'s size changed. But I am now more

4条回答
  •  名媛妹妹
    2021-02-13 12:24

    As of July 2020, ResizeObserver is still un-official in W3C nor WhatWG but it is already supported by all major browsers since support Safari 13.1 since 2020-Mar-24.


    FYI, there's a spec for a new ResizeObserver API. Chrome seems to be the only browser that has implemented it as of Aug 2018 (see caniuse.com), but there's at least one polyfill you can use now (which uses MutationObserver).

提交回复
热议问题