Your code is pretty close to what you need. I think the main problem is your styles and understanding of how they interact with the effect.
The bend effect will show or hide elements depending on their current state. You have a .fold class that runs your .fold with 0x0 pixels and hidden, but what you really want is a rule that describes how your divs look when displayed to your users.
Original:
.fold { display: none; width: 0; height: 0; position: absolute; }
Fixed:
.fold { width: 500px; height: 500px; position: absolute; }
Since your .fold style now describes the final state of your divs, it no longer has a display: none; rule display: none; . Since you want divs to be hidden first, you have to add Javascript to hide them initially:
$(".fold").hide();
Now, instead of manually animating styles, you can use the bend effect:
Original:
// if there is visible fold element on page (user already clicked at least once on link) if (active.length) { active.animate({ width: "0" }, 200) .animate({ height: "0" }, 200, function () { // this happens after above animations are complete $(this).removeClass("active"); }) // clicking for the first time } if (active.attr("id") != page) { $("#" + page) .addClass("active") .animate({ height: "500px" }, 1000, 'linear') .animate({ width: "500px" }, 400, 'linear') }
Updated:
if (active.length) { active.toggle("fold", function () { $(this).removeClass("active"); }); } // clicking for the first time if (active.attr("id") != page) { $("#" + page) .addClass("active") .toggle("fold"); }
Now that it all works, I think you will want to play with some settings. The documentation for the bend effect shows that you can set the size of your element, how it folds, and also the folding order. To simulate the link you sent, I would set the size to 5, since your divs have a 5px border. I would also set horizFirst to true , as this shows your example.
I also decided to use toggleClass instead of addClass("active") and removeClass("active") . This led to simpler settings.
Here is the finished product:
$(".fold").hide(); var foldSettings = { easing: 'linear', duration: 1200, size: 5, horizFirst: true, complete: function () { $(this).toggleClass("active"); } } $("a").click(function () { var page = $(this).data("page"); if ($('div:animated').id != page) { var active = $(".fold.active"); // if there is visible fold element on page (user already clicked at least once on link) if (active.length) { active.toggle("fold", foldSettings); } // clicking for the first time if (active.attr("id") != page) { $("#" + page).toggle("fold", foldSettings); } } });
http://jsfiddle.net/z69zofxm/3/