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
- jQuery 1.2.3+
- jQuery Easing Plugin (optional)
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
- 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
- Version 1.1: tgz | zip
- Version 1.0: tgz | zip
- Source Code on GitHub
License
ElementStacks is licensed under MIT.
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
13 comments
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.
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.
amazing
Two thumbs up!
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
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
Wauw! Nice one! Definitely going to use it in my next project
that's awesome man ! COOL ! :D
keep it up. good luck.
Thanks!
hi,
nice plugin man. I like it and I use it my client site.
thanks.
Muito bom mesmo, pena que e tudo em inglês hehe ;/
mais obrigado por compartilhar :)
How do the images know where to return to after they have all been stacked? Meaning their original positions? Thanks :)
@Evan foreach the images after onload and store the original positions in data http://api.jquery.com/jQuery.data/