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

Custom Scheduler #224

Open pzuraq opened 6 years ago

pzuraq commented 6 years ago

This library has been awesome for us, but we're having some trouble integrating it into our JS framework. We use Ember.js, and most work in Ember is scheduled using some kind of global scheduler. Importantly, the schedulers integrate with our test suites to ensure that all work has been completed before the test completes.

Would it be possible to add an option to substitute a custom requestAnimationFrame function (essentially a wrapper function) for scheduling updates?

marcj commented 6 years ago

I'm not sure I understand: This library is listening on a resize event and modifies some html attributes so your used css-selectors are applied. Where exactly do you need intervention?

pzuraq commented 6 years ago

Right here:

https://github.com/marcj/css-element-queries/blob/master/src/ResizeSensor.js#L223

We put all of our usage of requestAnimationFrame app-wide into this scheduler: https://github.com/html-next/ember-raf-scheduler and watch for items being pushed into it during tests to make sure the entire RAF queue has been flushed. We also use it for things like debouncing, but it seems like you've already done that internally with the EventQueue so that's definitely helpful!