Jquery .animate, make a div enter from off screen, float accross, exit off the screen, & repeat -
i've began teaching myself how use jquery functions, , can figure things out own own (and google of course). today out of ideas , find myself going in circles hoping can me out.
okay, here page working with: https://dl.dropboxusercontent.com/u/60521097/servzoo/html/index.html
basically, want have cloud divs enter off screen left, float right side (going behind center element), exit off screen, & repeat. have fiddled day , have gotten point dont know way anymore :-/ alright, here is...
#bg-wrapper { max-width:2920px; overflow: hidden; margin: 0 auto; background: url(images/untitled-3.jpg) left top; background-size: 100% 924px; background-repeat:no-repeat; background-attachment: fixed; } #bg-inner { width:2305px; height: 1080px; position: absolute; overflow: hidden; margin:0px; } #cloudone { position:absolute; margin-top:5px; margin-left:-200px; z-index: 1; filter:alpha(opacity=80); /* css3 standard */ opacity:0.8; } #cloudtwo { position:absolute; margin-top:85px; margin-left:-300px; z-index: 2; filter:alpha(opacity=60); /* css3 standard */ opacity:0.6; } #cloudthree { position:absolute; margin-top:65px; margin-left:-600px; z-index: 4; filter:alpha(opacity=70); /* css3 standard */ opacity:0.7; } #boat { margin-top:620px; position:absolute; margin-right:-2105px; z-index: 6; }
and script...
$(document).ready(function() { settimeout("cloudone()",10); settimeout("cloudtwo()",13); settimeout("cloudthree()",18); settimeout("boat()",40); }); function cloudone(){ $("#cloudone").animate({left:"600px"},5000).animate({right:"600px"}, 5000) settimeout("cloudone()",10000); } function cloudtwo(){ $("#cloudtwo").animate({left:"700px"},7000).animate({right:"700px"}, 6000) settimeout("cloudtwo()",13000); } function cloudthree(){ $("#cloudthree").animate({left:"1000px"},10000).animate({right:"1000px"}, 8000) settimeout("cloudthree()",18000); } function boat(){ $("#boat").animate({right:"2105px"},20000).animate({left:"2105px"}, 20000) settimeout("boat()",40000); }
by adding function animate
parameters, function called once animation completed. inside function, can reset position of cloud. after reset position, can use timeout restart animation you've done.
$("#cloudone").animate({left:"600px"},5000,function(){$("#cloudone").css({"left":"0px"});});
Comments
Post a Comment