WickyNilliams / enquire.js

Awesome Media Queries in JavaScript
http://wicky.nillia.ms/enquire.js/
MIT License
3.63k stars 269 forks source link

Add after callback to be called at the end of the addHandler call #133

Closed ericfreese closed 9 years ago

ericfreese commented 9 years ago

This commit adds an after option to the object passed as the second argument to enquire.register. If supplied, it will be triggered once immediately after registration of the handler.

This allows you to execute any code after the handler has been added, regardless of whether the handler was called or not.

In my use case, I'm using enquire to move a block of content into a sidebar if a media query matches. I needed to execute some code after the block was either moved or wasn't, and this allows me to do that.

Let me know what you think!

ericfreese commented 9 years ago

I've thought about this more and I'm pretty sure this makes absolutely no sense. I should be able to just put my code after the call to register and get the behavior I want.

Nevermind.