Baraja is an experimental and fun jQuery plugin that allows to move elements in a card-like fashion and spread them like one would spread a deck of cards on a table. It uses CSS transforms for rotating and translating the items. There are several options available that will create various spreading possibilities of the items, for example, moving the items laterally or rotating them in a fan-like way.

Please note that the CSS transforms and transitions only work in browsers that support them.

For using the plugin, an unordered list with the class “baraja-container” is expected, i.e. in our demo we use:

The following methods are available: fan(), next(), previous(), close(), add().

The default setting for the fan method are the following:

this.fanSettings = {
// speed for opening/closing
speed : 500,
// easing for opening/closing
easing : 'ease-out',
// difference/range of possible angles that the items will have
// example: with range:90 and center:false the first item
// will have 0deg and the last one 90deg;
// if center:true, then the first one will have 45deg
// and the last one -45deg; in both cases the difference is 90deg
range : 90,
// this defines the position of the first item
// (to the right, to the left)
// and its angle (clockwise / counterclockwise)
direction : 'right',
// transform origin:
// you can also pass a minX and maxX, meaning the left value
// will vary between minX and maxX
origin : { x : 25, y : 100 },
// additional translation of each item
translation : 0,
// if the cards should be centered after the transform
// is applied
center : true,
// add a random factor to the final transform
scatter : false
};

The basic styling is defined in the baraja.css file and you can see an example of customizing the style in custom.css.

The demo contains many examples of spreading possibilities and it also contains a navigation, an example of how to add more items and a close button that will trigger the deck of items to be brought back to their “closed” state. Clicking the first item will also trigger the deck to close. Clicking on an item inside of the deck will make it appear on top of the deck.

Note that depending on how many items you have, they will spread happily according to the parameters set. Because the items are absolute, they will simply overflow, so you might want to make sure that they stay in the viewport. You will be able to see that in some examples in the demo.

What a wonderful effect ! Love it at first glance. Thinking of if it’s possible to implement a lightbox effect where you can click the images or text so you can have bigger view. Any ideas? Btw great tutorials!