This is how I made the sliding effect on this page: dmg-01.net:
$(document).ready(function(){
$(".trail-text").attr("style", "display:none;");
if ($("#one,#two,#three,#four,#five")) {
var pixies = $("#one,#two,#three,#four,#five");
$("#one,#two,#three,#four,#five").hover( function() {
$(this).find(".trail-text").slideDown("fast");
}, function() {
$(this).find(".trail-text").slideUp("fast");
});
};
});
I would like to improve it because it’s not as graceful as I want. I think it would be better if only one slide effect occur at the same time with no overlapping.
On the other hand, I tried to accomplish the same effect this way:
$(function(){
$("#one,#two,#three,#four,#five").each(function(){
$(this).hover(function(){
$(this).animate({height: "100%", width: "100%"}, {queue:false, duration:111});
},function() {
$(this).animate({height: "44px", width: "44px"}, {queue:false, duration:333});
});
});
});
I discarded it because I don’t know how to set “auto” for height and the content inside the “hidden” elements are visible outside the element.
How can this be improved?
According to my purpose, I prefer to animate with CSS properties the descendants of the elements. This is how I tried to do it but it isn’t working. Why?
$(document).ready(function(){
$(".trail-text").attr("style", "display:none;");
if ($(".#one,#two,#three,#four,#five")) {
$("#one,#two,#three,#four,#five").hover(
function() { $(this).find(".trail-text").animate({height: "100%", width: "444px"}, {queue:false, duration:111}); },
function() { $(this).find(".trail-text").animate({height: "0", width: "444px"}, {queue:false, duration:333}); }
);
};
});
Finally, I improve the effect with this trick.
However, I would have preferred
.animateinstead of.slideDown/Upso I can add CSS properties. Anyway, the animation is smooth and I’m satisfied. Thank you for your advice and improvements!