cloud.js 959 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. // Cloud Float...
  2. var $main = $cloud = mainwidth = null;
  3. var offset1 = 450;
  4. var offset2 = 0;
  5. var offsetbg = 0;
  6. $(document).ready(
  7. function () {
  8. $main = $("#mainBody");
  9. $body = $("body");
  10. $cloud1 = $("#cloud1");
  11. $cloud2 = $("#cloud2");
  12. mainwidth = $main.outerWidth();
  13. }
  14. );
  15. /// 飘动
  16. setInterval(function flutter() {
  17. if (offset1 >= mainwidth) {
  18. offset1 = -580;
  19. }
  20. if (offset2 >= mainwidth) {
  21. offset2 = -580;
  22. }
  23. offset1 += 1.1;
  24. offset2 += 1;
  25. $cloud1.css("background-position", offset1 + "px 100px")
  26. $cloud2.css("background-position", offset2 + "px 460px")
  27. }, 70);
  28. setInterval(function bg() {
  29. if (offsetbg >= mainwidth) {
  30. offsetbg = -580;
  31. }
  32. offsetbg += 0.9;
  33. $body.css("background-position", -offsetbg + "px 0")
  34. }, 90 );