marcj/css-element-queries

Can't create a new ResizeSensor without a callback

andi-b opened this issue · 4 comments

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

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

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

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

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