- This topic is empty.
-
AuthorPosts
-
June 1, 2013 at 7:43 pm #45167
Anonymous
Inactive//automatic panel_one expand on load. to remove the automatic expand remove the 3 lines bellow.
$(document).ready(function() {
$(“#panel_one”).stop().animate({height:’265px’},400);
});
//first panel
$(“#panel_one”).click(function() {
$(this).animate({height:’265px’},300);
$(“#panel_two”).animate({height:’110px’},300);
$(“#panel_three”).animate({height:’110px’},300);
$(“#panel_four”).animate({height:’110px’},300);
});//second panel
$(“#panel_two”).click(function() {
$(this).animate({height:’265px’},300);
$(“#panel_one”).animate({height:’110px’},300);
$(“#panel_three”).animate({height:’110px’},300);
$(“#panel_four”).animate({height:’110px’},300);
//fadein when hovering
});//third panel
$(“#panel_three”).click(function() {
$(this).animate({height:’265px’},300);
$(“#panel_one”).animate({height:’110px’},300);
$(“#panel_two”).animate({height:’110px’},300);
$(“#panel_four”).animate({height:’110px’},300);
//fadein when hovering
});//fourth panel
$(“#panel_four”).click(function() {
$(this).stop().animate({height:’265px’},300);
$(“#panel_one”).animate({height:’110px’},300);
$(“#panel_two”).animate({height:’110px’},300);
$(“#panel_three”).animate({height:’110px’},300);
//fadein when hovering
});This is the code for the tiles expand and shrink of this website. http://reallycoolstuff.net/PROJECTS/Unica/
June 1, 2013 at 8:28 pm #137292TheDoc
MemberNeeds almost no jQuery at all: http://codepen.io/ggilmore/pen/2e94c46117837e4898c344d5b4230faf
June 1, 2013 at 8:29 pm #137293TheDoc
MemberBut the first problem with your code is that you are being too specific with your selectors. DRY (Don’t Repeat Yourself) is something that is being completely ignored here. Imagine if you wanted to add three more panels, it’d be a pain in the ass!
June 1, 2013 at 10:11 pm #137300Anonymous
Inactive@TheDoc i forgot to mention that i don’t want to use CSS animation because it is not supported in IE browsers. Only jQuery.
June 1, 2013 at 10:19 pm #137301TheDoc
MemberI completely disagree with supporting animations in legacy browsers. IE7-9 don’t *need* to see the height animating. The product still functions flawlessly.
Now, if you *must* have it, for reasons I’ll never understand, you could do this: http://codepen.io/ggilmore/pen/7ba4d2ceaeac063cf1ff18f0dce8b14b
June 2, 2013 at 11:43 am #137353Anonymous
Inactive@TheDoc works like a charm. Although how do i change the speed?
June 2, 2013 at 4:24 pm #137384TheDoc
MemberJust by adding the duration parameter: http://codepen.io/ggilmore/pen/7ba4d2ceaeac063cf1ff18f0dce8b14b
June 2, 2013 at 5:58 pm #137380Anonymous
Inactive@TheDoc Thanks.
-
AuthorPosts
- The forum ‘CSS’ is closed to new topics and replies.