Elastic Stack: Elastic Dragging Interaction

ElastiStack is a little script that let's you navigate through a stack of items by dragging away the first one. It comes with an elastic touch meaning that when dragging the top-most item, the other ones will follow as if they were connected elastically. When reaching a certain distance, the dragged item will release itself and the next item will pop out.

From our sponsor: Market smarter with Mailchimp's automated messaging tools.

Today we’d like to share a little script that lets you navigate through a stack of thumbnails with an elastic touch. The idea comes from this Dribbble shot by CreativeDash and the interaction is basically dragging an item up to the point that it “releases” from the stack which it seems to be connected to with an invisible elastic. For the dragging functionality we are using David DeSandro’s Draggabilly.

Three items are visible initially, the main one and the the two next ones, which can be seen because we’ve added some perspective to the item list and translated the two items on the Z-axis. When dragging the top-most item, we’ll also drag those two items along creating the elastic illusion.

The HTML structure that we are working with is the following:

<ul id="elasticstack" class="elasticstack">
	<li><img src="img/1.jpg" alt="01"/><h5>Saudade</h5></li>
	<li><img src="img/2.jpg" alt="02"/><h5>Tuqburni</h5></li>
	<li><img src="img/3.jpg" alt="03"/><h5>Retrouvailles</h5></li>
	<li><img src="img/4.jpg" alt="04"/><h5>Onsra</h5></li>
	<li><img src="img/5.jpg" alt="05"/><h5>Mamihlapinatapai</h5></li>
	<li><img src="img/6.jpg" alt="06"/><h5>Koi No Yokan</h5></li>

When the first item gets dragged, we’ll want it to bounce back if it’s dropped too close to the stack. That distance can be define in the variable distDragBack. The area that will make the item disappear when dropped into is defined by the distance set as distDragMax. Dragging the item beyond that distance will automatically release the item from the stack, no dropping necessary. This graphic shows the distances:


And this is how you can initialize the script:

new ElastiStack( element, {
	// distDragBack: if the user stops dragging the image in a area that does not exceed [distDragBack]px 
	// for either x or y then the image goes back to the stack 
	distDragBack : 200,
	// distDragMax: if the user drags the image in a area that exceeds [distDragMax]px 
	// for either x or y then the image moves away from the stack 
	distDragMax : 450,
	// callback
	onUpdateStack : function( current ) { return false; }
} );

The beautiful illustrations used in the demo are by talented artist Guzk. They belong to the set Memoria de Ataun. Check out the artist’s Behance portfolio and website. Contact us if you’d like to be featured in one of our demos.

We hope you enjoy this experiment and find it useful!

Tagged with:

Mary Lou

ML 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.


Stay up to date with the latest web design and development news and relevant updates from Codrops.

CSS Reference

Learn about all important CSS properties from the basics with our extensive and easy-to-read CSS Reference.

It doesn't matter if you are a beginner or intermediate, start learning CSS now.

Feedback 29

Comments are closed.
  1. I love it! I think I saw a similar effect somewhere a while ago and thought about recreating it but then completely forgot about it. =p

    I also love the images you’re using! <3

  2. Hi Mary Lou, it’s a amazing work! Tks very much for sharing! I was thinking (not try yet), if there is a way to put some “next” and “back” buttons, so, we can drag the image or click on buttons to move to next photo or go back! I was thinking about that because we can move forward on gallery, but if are some photo that we want to see, we need to go through all gallery! If someone has some highlights thoughts about that, plz share =)

  3. Hi!
    Very nice script! Congratulations!
    There is also the possibility to make it work on IE8?
    I met a couple of problems:
    the first, which I resolved, you add the method “call” on that ie8 does not exist in this way:

    (function() {
    if(navigator.appVersion.indexOf('MSIE 8') > 0) {
    var _slice = Array.prototype.slice;
    Array.prototype.slice = function() {
    if(this instanceof Array) {
    return _slice.apply(this, arguments);
    } else {
    var result = [];
    var start = (arguments.length >= 1) ? arguments[0] : 0;
    var end = (arguments.length >= 2) ? arguments[1] : this.length;
    for(var i=start; i<end; i++) {
    return result;

    the second, which I can not fix, it is a mistake “Message: Object doesn’t support this property or method Line: 138 Char: 5” at line 138:

    instance.element.removeEventListener( transEndEventName, onEndTransFn );

    There is a hack to make this wonderful plugin for ie8?


  4. Hi It is really nice on. Can you help me to remove the swiped slides data from stack?

  5. Really nice project. I am in a problem with this. I want to get first slid in different background color. How can I do that? Please help me.

  6. Hello,

    It is really nice work, and like it. Could you please help me to add LEFT & RIGHT Arrows ( Button ) for the transition to left and right accordingly.
    I would like to add two button/arrow actions other than the swiping events.

  7. Hi,

    Its Really Great Script. Can you help me to integrate the left and right button click functionality to this application