Skip to content

Instantly share code, notes, and snippets.

@carlmw
Created September 21, 2010 20:40
Show Gist options
  • Save carlmw/590488 to your computer and use it in GitHub Desktop.
Save carlmw/590488 to your computer and use it in GitHub Desktop.
// I was just thinking it would be pretty useful to be able to listen for the wfl events
// in a context outside the WebFontConfig object. In particular
// today I found a situation where I needed to supply several handlers in different contexts.
// In the end I used a shim to dispatch a custom event via jquery.
var WebFontConfig = {
active: function(){
$(window).trigger('wf-active');
}
};
// I figured it would be pretty cool to be able to listen for a custom event
window.addEventListener('wf-active', function(){
// Do something when fonts are available
});
// Maybe I've misread the docs and something similar is already possible. Hope that makes sense :)
@seanami
Copy link

seanami commented Sep 21, 2010

Yep, our font event callbacks don't also fire custom browser events that other event libraries would pick up. Your shim is probably the easiest way to accomplish this right now, and hopefully not too annoying.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment