How to detect CSS3 resize events

前端 未结 6 1275
庸人自扰
庸人自扰 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:25

    Since the resize event clearly doesn't work (currently, at least), you can try one of these alternative options:

    1. Use a combination of mousedown, mousemove and/or mouseup to tell whether the div is being / has been resized. If you want really fine-grained control you can check in every mousemove event how much / if the div has been resized. If you don't need that, you can simply not use mousemove at all and just measure the div in mousedown and mouseup and figure out if it was resized in the latter.
    2. Poll every 200ms or so (depending on your needs) and compare the current size with the last known size. See setTimeout().

提交回复
热议问题