Created
September 21, 2010 20:40
-
-
Save carlmw/590488 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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 :) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.