How to detect CSS3 resize events

前端 未结 6 1273
庸人自扰
庸人自扰 2020-12-01 15:42

The CSS3 resize property can be assigned to arbitrary elements. I\'m looking for a way to detect such a resize on, say, divs (I don\'t mind it only working in Firefox at the

6条回答
  •  無奈伤痛
    2020-12-01 16:29

    Resizing is like a style change. As such it can be observed with a MutationObserver.

    let observer = new MutationObserver(function(mutations) {
      console.log('mutations:', mutations);
    });
    
    let child = document.querySelector('textarea');
    observer.observe(child, { attributes: true });

提交回复
热议问题