Saturday, 17 August 2013

Event handler for web fonts load?

Event handler for web fonts load?

I've got a piece of code that wants to perform a jump to a particular id
on the page as soon as the page is ready. I accomplish this by performing
a jquery.animate() so that the scrollTop is at my target element.
However, I'm using web fonts, and for some reason the ready event is
firing before the web fonts have loaded and been applied. The result is
that the animation ends on a position that is often completely unrelated
to the actual position of the element I want to scroll to.
I've verified this by opening the timeline in the Chrome inspector, where
I see the animation triggering, followed by the web font loading, followed
by a re-render which causes my animation target scroll point to become
meaningless. I've also confirmed that this issue does not manifest itself
when I use a system font.
Could anyone offer some advice? Perhaps there's some sort of event that
fires after a web font has been applied?

No comments:

Post a Comment