Filter & sort magical layouts http://isotope.metafizzy.co
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

66 lines
1.9 KiB

---
title: Troubleshooting
category: docs
layout: doc
related: z-etc
---
14 years ago
## Unloaded media
14 years ago
Most layout modes (i.e masonry, fitRows) need to measure the size of each item to appropriately account for its space in the layout. Unloaded media files like images and @font-face fonts can throw off layout and cause item elements to overlap one another. Ideally, Isotope layouts should be initialized after all inner content has loaded.
14 years ago
## Images
14 years ago
### Inline dimensions
For images, the best method is to specify the width and height of images inline.
{% highlight html %}
<img src="img-file.jpg" width="280" height="160" />
{% endhighlight %}
If you’re using a PHP-based CMS, you can use the [getimagesize](http://php.net/manual/en/function.getimagesize.php) function.
14 years ago
### imagesLoaded plugin
The next best solution is to use the imagesLoaded plugin included with Isotope. It's a fork of [Paul Irish's plugin](https://gist.github.com/268257) that finds all the images in a context, and fires a callback function once all the images have loaded.
{% highlight javascript %}
$('#container').imagesLoaded( function(){
$(this).isotope({
itemSelector : '.item',
});
});
{% endhighlight %}
14 years ago
### `$(window).load()`
Another solution is to initialize Isotope inside `$(window).load()` instead of `$(document).ready()`.
{% highlight javascript %}
$(window).load(function(){
$('#container').isotope({
// options...
});
});
{% endhighlight %}
14 years ago
## @font-face fonts
Both Typekit and Google WebFont Loader provide font events to control scripts based on how fonts are loaded.
+ [Typekit font events](http://blog.typekit.com/2010/10/18/more-control-with-typekits-font-events/)
+ [Google WebFont Loader: Events](http://code.google.com/apis/webfonts/docs/webfont_loader.html#Events)
Additionally, you can use the `$(window).load()` pattern above to wait for all content, including @font-face fonts, to load before initializing Isotope.