I am working on a WP slider and want to use differnt animations based on the number of divs in the slider loop. Below is what I have so far, it workes fine with just one if statment but I want to use multiple if statements.
Can anyone help? Thanks in advance for looking :)
jQuery(document).ready(function(){
var tl = new TimelineMax({repeat:-1}),
slide1 = document.getElementById("slide1"),
head1 = document.getElementById("head1"),
sub1 = document.getElementById("sub1"),
p1 = document.getElementById("p1"),
slide2 = document.getElementById("slide2"),
head2 = document.getElementById("head2"),
sub2 = document.getElementById("sub2"),
p2 = document.getElementById("p2"),
n = jQuery("#slider div").length;
if (n == 2) {
tl.to(slide1, 1, {left:0 }, "slide10end")
.from(head1, 1, {left:-1000}).to(head1, 1, {top:50}).to(head1, 1, {top:50}).to(head1, 1, {opacity:0})
.to(sub1, 1, {right:-200}).to(sub1, 1, {rotation: 720}).to(sub1, 1, {opacity:0})
.from(p1, 1, {scale:0}).to(p1, 1, {scale:1}).to(p1, 1, {scale:0})
.to(slide1, 1, {left:-2000 }, "slide1end")
}
else if (n == 3) {
tl.to(slide1, 1, {left:0 }, "slide10end")
.from(head1, 1, {left:-1000}).to(head1, 1, {top:50}).to(head1, 1, {top:50}).to(head1, 1, {opacity:0})
.to(sub1, 1, {right:-200}).to(sub1, 1, {rotation: 720}).to(sub1, 1, {opacity:0})
.from(p1, 1, {scale:0}).to(p1, 1, {scale:1}).to(p1, 1, {scale:0})
.to(slide1, 1, {left:-2000 }, "slide1end")
.to(slide2, 1, {left:0 })
.from(head2, 1, {left:-1000}).to(head2, 1, {left:-1000, delay:1})
.to(sub2, 1, {right:-200}).to(sub2, 1, {right:-2000, delay:1, opacity:0}).to(sub2, 3, {right:-2000}, "-=0.9")
.from(p2, 1, {left:-2000, ease:Bounce.easeOut}).to(p2, 1, {opacity:0, delay:1})
.to(slide2, 1, {left:-2000 }, "slide2end")
}
else (n == 4) {
//slider 3
tl.to(slide3, 1, {left:0 })
.from(head3, 1, {left:-1000}).to(head3, 1, {left:-1000, delay:1})
.to(sub3, 1, {right:-200}).to(sub3, 1, {right:-2000, delay:1, opacity:0}).to(sub3, 3, {right:-2000}, "-=0.9")
.from(p3, 1, {left:-2000, ease:Bounce.easeOut}).to(p3, 1, {opacity:0, delay:1})
.to(slide3, 1, {left:-2000 }, "slide2end")
}
});