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

Can't create a new ResizeSensor without a callback #275

Closed andi-b closed 4 years ago

andi-b commented 5 years ago

I can't create a new Resize sensor without passing through an empty function:

new ResizeSensor($(this), function () { });

The code assumes that a function will always be passed through and tries to call it.

marcj commented 4 years ago

Why would you want to create a sensor without using its emitted values?

andi-b commented 4 years ago

You may want to dynamically add a new element to the dom and add the sensor to it so that it works with the conditional css, but not have a function to call when the new element resizes.

marcj commented 4 years ago

You should call ElementQueries.init() when you dynamically added new elements. However, usually the animation-hook automatically finds those elements.

andi-b commented 4 years ago

Of course that makes total sense. Not sure animation hook did, but will keep that in mind. Thanks!