size-listener

A hack method to listen the dom when dom size changed

Usage no npm install needed!

<script type="module">
  import sizeListener from 'https://cdn.skypack.dev/size-listener';
</script>

README

size-listener

通过scroll间接监听元素尺寸变化

image

使用方法:

npm install size-listener
// listen
import SizeListener from "size-listener";
const cb = function(width:number, height:number){ console.log(width, height) };
const dom = document.querySelector(".target");
const listener = new SizeListener(dom, cb);
// destroy
listener.destroy();