【发布时间】:2012-04-29 12:47:19
【问题描述】:
我正在使用masonry 和typekit。因此,由于图像加载,我希望布局为not have overlapping,同时render the typekit fonts without having the default fonts being shown in a flash when we first load the page。
因此,我需要 javascript 代码来处理这两个问题:重叠砌体中的图像和正确加载 typekit 字体。
我的 javascript 文件中有以下代码可以完美加载砌体,但我无法正确加载 typekit 字体。当网站第一次加载时,它会显示默认的 Times New Roman 字体,然后在闪烁后显示 typekit 字体。
如何修改我的 javascript 代码?
//trigger masonry and typekit
var $container = $('#wrapper');
function triggerMasonry() {
if ( !$container ) {
return
}
$container.imagesLoaded(function(){
$container.masonry({
itemSelector : '.box',
columnWidth : 240
});
});
}
$(function(){
$container = $('#wrapper');
triggerMasonry();
});
Typekit.load({
active: triggerMasonry,
inactive: triggerMasonry
});
【问题讨论】: