marcj / css-element-queries

CSS Element-Queries aka Container Queries. High-speed element dimension/media queries in valid css.
http://marcj.github.io/css-element-queries/
MIT License
4.27k stars 487 forks source link

added ResizeCallback to ResizeSensor.d.ts and added static functions … #248

Closed coalman closed 5 years ago

coalman commented 5 years ago

…to ResizeSensor class

This adds a ResizeCallback type instead of Function and adds the static detach/reset functions to ResizeSensor.

This allows the following:

const callback: ResizeSensorCallback = (size) => {
  console.log(size.width); // size.width is a number
  console.log(size.height); // size.height is a number
};

const sensor = new ResizeSensor(element, callback);
ResizeSensor.detach(element, callback); // type checked args
ResizeSensor.reset(element); // type checked args
sensor.detach(callback); // type checked arg
sensor.reset(); // type checked
marcj commented 5 years ago

Cool thanks!