Dynamic Grid with Transitions

A dynamic grid layout that let's you choose how many rows and columns of items are shown. Partly based on the visualization of Google Trends, except that you can add transitions.

DynamicGrid

View demo Download source

You have surely seen the latest cool visualization of Google Trends, where the latest hot searches from Google Trends are shown in a colorful grid and where you can control the amount of items with a little grid control in the top left corner.

Regardless of the great swipe effect in the grid boxes, we really loved the idea of changing a layout dynamically with a control. Another great thing is that the boxes’ dimensions are percentage-based which makes them fluid. We couldn’t help but wonder how it would look if we’d added transitions to the grid where we could actually see what’s happening when changing from a let’s say 5 × 5 layout to a 2 × 3 one.

GoogleTrendsGrid

So we tried to create something similar: a dynamic grid layout where we can choose to have transitions with or without delays. The transition itself is set in the JavaScript, but in the CSS we can define what happens to the items that disappear (for example, scale down or rotate, etc.).

Please note that this only works as intended in browsers that support the respective CSS properties.

DynamicGridAnimationSmall

What we are doing is to calculate the positions and the dimensions of the boxes and set them according to the chosen grid layout. The values are percentage-based which makes the boxes fluid. Once we change the grid layout, a special class will be applied to the items that need to be hidden (i.e. the once we won’t see in the viewport anymore) which will optionally trigger a transition and do what you define in the class to be done (for example, scale them down or rotate them) and hide them.

For eventual rounding errors we are using calc() to add one pixel to the calculated percentage. Although that might not be the perfectly correct value, it will avoid the appearance of gaps between the items. For browsers that don’t support calc(),* [W]e’ll be adding half a percent to the width and height to avoid any gaps. *Woah, Safari does not seem to like transitioning to a calc() value at all: https://bugs.webkit.org/show_bug.cgi?id=100568. That does not seem to be resolved. So now we are using the fallback for every browser.

Note that Modernizr is used for detecting the support for calc() and touch. We are also using classie.js by David De Sandro.

An example for how to initialize the grid is the following:

Grid.init( {
	transition : true,
	speed : 450,
	delay: 20
} );

Demos

Check out the demos with the different configurations:

We hope you like and enjoy it and find it useful!

View demo Download source

Previous:
Next:

Tagged with:

Mary Lou (Manoela Ilic) is a freelance web designer and developer with a passion for interaction design. She studied Cognitive Science and Computational Logic and has a weakness for the smell of freshly ground peppercorns.

View all contributions by

Website: http://tympanus.net/

Related Articles

Feedback 30

  1. 1

    Amazing work here!

    I’m currently tearing it apart for a specific project. Looking for a quick way to change to a specific grid size by binding the click event to another div/a on the page (eg. Clicking a menu item triggers the transition to 5×5), without having to rewrite any of your brilliant js.

    Thanks!

  2. 2

    Mary as usual your demos are incredible and inspirational.
    Please keep making the source freely available for those that can “dig” and “tinker”

Follow this discussion

Leave a Comment

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>