Summer 2013 update

9 Aug 2013 · by David DeSandro

Oh man, while you've been trying to keep cool in the summer shade, the codes have been BLAZING.

Masonry v3

The trendiest piece of JS in 2011 got a full overhaul for a new era. Masonry v3 comes with two big wins:

  • removed jQuery dependency
  • added support for responsive layouts with element sizing

If you take a look at the source code, you'll see that the actual Masonry code is just over 200 lines. "WHAT?! That's crazy!" you say? Actually, Masonry's code is so small because all the boring stuff is handled by a parent layout library called...

Outlayer

Outlayer is "the guts and brains of a layout library." Most of the functionality in Masonry, Isotope, and Packery is the same stuff. Items, resizing, appending, transitioning, yadda yadda yadda. Really, the only difference between these libraries is the algorithm used to position item elements.

Outlayer abstracts all the general work to be done, so that the separate layout libraries focus just on what make them special. Bower puts it all together.

This is a win for users, as it will help centralize work and bug fixes. A bug fixed for Masonry can mean a bug fixed for Packery and Isotope.

Packery v1.1

Packery has since been updated, utilizing Outlayer as its core. Packaged versions of Packery v1.1 and Masonry v3 share about 75% of the same code. Neat!

Upcoming Isotope v2

All this work on layout libraries means that the stage is set to take on the mamma bear, Her Majesty Queen Isotope. Work has already begun on the big re-write. I'm aiming for a release in October.

imagesLoaded v3

27 May 2013 · by David DeSandro

imagesLoaded just got a big upgrade this week. It just got a whole lot more reliable and consistent across browsers.

imagesLoaded

Prior to the fresh version 3, imagesLoaded relied on a hack, flipping out an images src in order to clear it from a browser cache. Now, the script checks for naturalWidth, and then fallbacks to listening for load or error event on proxy images.

You can thank @Darsain for revising the code. Checking for loading images is actually a tricky endeavor, as various browsers have bizarre quirks involved with loading and caching images. This latest revision is a fine piece of work, as it resolves all the previous bugginess. I owe you, Tomas.

imagesLoaded is an important component library for Masonry, Isotope, and Packery. Without it, using images in dynamic layout libraries would be slow and ugly. I'm jazzed to keep support for this resource going, in its third year of development.

Packery released

14 Apr 2013 · by David DeSandro

Packery, the bin-packing layout library, is out. Packery is the second product from Metafizzy. We now have a product line.

packery.metafizzy.co

packery site

Packery is a JavaScript layout library that uses a bin-packing algorithm. This is a fancy way of saying "it fills empty gaps." Packery layouts can be intelligently ordered or organically wild. Elements can be stamped in place, fit in an ideal spot, or dragged around.

Packery is the successor to Isotope and Masonry. Together, they make a wonderful family of dynamic layout libraries. This is an important distinction. Packery was not created in a vaccuum. It is not a complete innovation. Packery was developed out of Isotope, and Masonry before it. As I see it, I've been working on this one problem -- layouts with JS -- for four years.

Packery resolves some of the more recent issues with Masonry and Isotope and their support for responsive layouts. Sizing options can accept elements, which allows you determine the size of the option by controlling its size in CSS. Eventually, I'd like to port over this and other solutions developed in Packery to Masonry and Isotope.

The algorithm

The cornerstone of this project is the bin-packing algorithm. That algorithm was taken from a white paper, A Thousand Ways to Pack the Bin -- A Practical Approach to Two-Dimensional Rectangle Bin Packing, by Finish developer Jukka Jylänki (shared with me by Wes Dimiceli. Thank you so much Wes). The paper discusses several algorithms for essentially fitting lots of rectangles into a much bigger rectangle. The Packery algorithm is based off of Jylänki's Maximal Rectangles algorithm.

maximal rectangle algorithm

maximal rectangle algorithm

How it works is not that fascinating (if you're interested, read the paper), but what it provides is delicious. This algorithm was the key to unlocking some of Masonry's most fantasized features: dragging, and filling in gaps. It opens up new possibilities, like fitting in expanded items and stamping other elements in place.

Bower

Packery uses vanilla JavaScript and no jQuery whatsoever. Years ago, it was impossible to get anything done without jQuery. Modern browser platforms have evolved so much, that jQuery's feature-set is no longer a must have.

That's not to say Packery is lightweight. In order to fill-in all the features that jQuery would provide, I had to go and either find or build each component. Packery utilizes several smaller libraries:

Bower makes this component-ized development possible. By encapsulating each feature-set in its own micro-library, a developer can focus on fulfilling well-defined libraries. Packery just handles the layout. getSize just handles measuring sizes. EventEmitter just handles event emitting. As each component is separate, they can built on top of one another as load-bearing structures of other libraries.

As Bower is still in v0.x development, in order to make Packery, there was work to be done to Bower. 2013 is going to be a big year for Bower. I hope Packery helps Bower make it big.

You can install Packery with Bower.

bower install packery

I am excited for what's to come. Packery layouts have tremendous potential for innovation for web layouts. But there's a danger that comes with changing the rules so much. What will happen now that developers have their mythical drag n' drop multi-column grid plugin? I hope good things. But once these tools are out in wild, who knows how they will be used.

Packery preview

10 Feb 2013 · by David DeSandro

I'm making a new layout library, called Packery. It is awesome because it resolves two of biggest and oldest issues with Masonry or Isotope.

It's been in development for the past several months, and it still has a ways to go until a full public release. Here's a sneak peek.

Packery has support for grid layouts. Okay, this isn't anything new from Masonry...

Packery grid

... but you can go totally off the grid and have lots of random item sizes. Packery is perfect for this.

Packery

For next couple preview images, we'll have to use the best imagery format of all time: GIFs.

Behold, Packery fills in the gaps! As well as adding and removing item elements.

Packery fill in gaps

Packery does responsive stuff. The red background indicates a breakpoint.

Packery responsive

Much to my chagrin, Masonry's corner stamp feature is fairly popular. Packery goes all-out on this concept, allowing you to arbitrarily place certain elements anywhere you like. Note how the gray elements are laid out around the red ones.

Packery placed elements

Here come the big guns. Draggable layout.

Packery draggable

And draggable grid layout. Packery will align 'dropped' item elements into it's proper place in the grid.

Packery draggable grid

With multi-touch support

Packery draggable multi-touch

Mic. Dropped.

But there's plenty of work to be done. I think most of the features are pretty solid, but I need to write the docs, and make demos, and do all the administration around making a legit digital product. In the next couple weeks, I hope to blog a bit more about the process.

Packery will be released soon. Hang on.

Sticker give-away!

5 Jan 2013 · by David DeSandro

Metafizzy stickers

2012 was a great year. In the spirit of celebration, we're giving away a bunch of stickers. These die-cut stickers are 3" × 3" in size, feature dazzling rainbows, and come in two varieties: script with gradient, or geometric with solid colors. They'll look awesome on your laptop or your cat.

Metafizzy stickers

Metafizzy stickers

The give-away is now over. Maybe next year!

Get started with jQuery Masonry by Luke Shumard

29 Dec 2012 · by David DeSandro

Earlier this year, .net magazine published Get started with jQuery Masonry, a terrific tutorial article by Luke Shumard.

Luke Shumard provides a crash-course in David DeSandro’s Masonry, a jQuery plug-in that’s ideal for both novice and intermediate web designers

.net magazine Get started with jQuery Masonry

.net magazine Get started with jQuery Masonry

I was happy to recommend Luke to write the article. As the developer behind the engaging fashion culture sites Dazed Digital and Satellite Voices, Luke has more production-level experience with Masonry than anyone else I know.