tumblelog detail

15.03.2010
ElementStack 1.1 for jQuery

ElementStacks 1.1 stacks elements/images on top of each other with a funky animation.

jQuery version of ElementStacks by Oskar Krawczyk.

New in 1.1:
  • you can now define the initial state to be collapsed
  • you can now define which stack item to be stuck with by using a static value (e.g. 'first', 'last') or a dynamic function

Dependencies

How to use

$(<wrapper>).elementStacks();

Options

  • itemsSelector: selector for the stackItems inside your wrapper. Default img.
  • rotationDeg: degree of the rotation. Default 20.
  • delay: delay between the animation of the elements. Default 40.
  • duration: duration of the animation for each element. Default 900.
  • transition: the name of the easing effect that you want to use. Default swing.
  • stuckWithItem (new in 1.1): null, ‘first’, ‘last’, function or index (0-based) of the stackItem to be stuck with. Default null.
    The function takes 2 arguments:
    • wrapper: DOM element defined by your principal selector in the elementStacks call
    • opts: options
    and returns the 0-based index of the stackItem you want to be stuck with.
  • initialCollapse (new in 1.1): true if you want the initial state of the stack to be collapsed. Default false.

Usage

Example 1: initialCollapse = true
Example 2: with stuckWithItem function

Using a function which returns a random index:

function(wrapper, opts) {
    var imgs = $(opts.itemsSelector, wrapper);
    return imgs[Math.floor(Math.random()*imgs.length)]
}

Download

License

ElementStacks is licensed under MIT.

(jquery)

13 comments

21.03.2010
Jul

Really nice updates on the plugin, thanks a lot!
I wonder if it's possible to have an external trigger to switch between collapsed and uncollapsed instead of clicking on a stack element.


24.03.2010
Marco Fucci

It shouldn't be too hard and it does make a lot of sense.
I'll start working on it when ( if? ) I have a little spare time.
Thanks a lot for your feedback.


07.05.2010
mj

amazing


19.05.2010
Max

Two thumbs up!


21.05.2010
thomas

yes, good idea. But it has a error. clicked thumbnail has index sometime is top, sometime is not. Your code is long. I have demo with my code: http://www.ngoduyit.com/demo/photos/index.htm


21.05.2010
Marco Fucci

Hi Thomas,
I know that my script has a bug, I haven't had enough time to fix it.
Nonetheless your version is incomplete:
- the images don't have delay during the transaction
- it isn't customizable
- it doesn't include progressive enhancement on Safari and Firefox


21.05.2011
Maarten Dings

Wauw! Nice one! Definitely going to use it in my next project


24.06.2011
sachin

that's awesome man ! COOL ! :D
keep it up. good luck.



14.11.2011
shahzadthathal

hi,
nice plugin man. I like it and I use it my client site.
thanks.


14.11.2011
Pablo Ribeiro

Muito bom mesmo, pena que e tudo em inglês hehe ;/

mais obrigado por compartilhar :)


06.12.2011
Evan

How do the images know where to return to after they have all been stacked? Meaning their original positions? Thanks :)


13.12.2011
Marco Fucci

@Evan foreach the images after onload and store the original positions in data http://api.jquery.com/jQuery.data/





Add your comment Your comment won't be synchronized with external services.

name: your real name

email: won't be published

website: (optional) your website

comment: your comment