index.js 3.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. // $(document).ready(function () {
  2. var imgdefereds = []; //定义一个操作数组
  3. $('.rocket-wrapper img').each(function () { //遍历所有图片,将图片
  4. var dfd = $.Deferred(); //定义一个将要完成某个操作的对象
  5. $(this).bind('load', function () {
  6. dfd.resolve(); //图片加载完成后,表示操作成功
  7. });
  8. if (this.complete) { //如果图片加载状态为完成,那么也标识操作成功
  9. setTimeout(function () {
  10. dfd.resolve();
  11. }, 10);
  12. }
  13. imgdefereds.push(dfd); //将所有操作对象放入数组中
  14. })
  15. $.when.apply(null, imgdefereds).done(function () { //注册所有操作完成后的执行方法
  16. var rocketImgs = document.querySelectorAll('.rocket-wrapper img');
  17. for (var i = 0; i < rocketImgs.length; i++) {
  18. rocketImgs[i].setAttribute('class', 'end');
  19. }
  20. document.getElementById('rocket_body').style.animation = 'rocket_body 2s linear 2.2s infinite';
  21. // document.getElementById('rocket_block_left_2').style = 'animation:rocket_block_left_2 3s linear 1s infinite';
  22. // document.getElementById('rocket_block_right_1').style = 'animation:rocket_block_right_1 3s linear 1s infinite';
  23. document.getElementById('rocket_halo_L').style.animation = 'rocket_halo_L 2s linear 2.2s infinite';
  24. document.getElementById('rocket_halo_L_fadeout').style.animation = 'rocket_halo_L_fadeout 2s linear 2.2s infinite';
  25. document.getElementById('rocket_tail_L').style.animation = 'rocket_tail_L 2s linear 2.2s infinite';
  26. document.getElementById('rocket_tail_S').style.animation = 'rocket_tail_S 2s linear 2.2s infinite';
  27. // document.getElementById('rocket_halo_S').style.animation = 'rocket_halo_S 2s linear 2.2s infinite';
  28. document.getElementById('rocket_halo_XS').style.animation = 'rocket_halo_XS 2s linear 2.2s infinite';
  29. document.getElementById('rocket_block_left_1').style.animation = 'rocket_block_left_1 4s linear 3.7s infinite';
  30. // document.getElementById('rocket_block_right_2').style.animation = 'rocket_block_right_2 4s linear 3.7s infinite';
  31. // 数字
  32. var i = 0,
  33. j = 0,
  34. k = 0;
  35. var windowWidth = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidht;
  36. var numberOne = document.getElementById('index_bg_number_1');
  37. var numberTwo = document.getElementById('index_bg_number_2');
  38. var numberThree = document.getElementById('index_bg_number_3');
  39. var rocketTimer = setInterval(function () {
  40. i += 11, j += 1, k += 2;
  41. if (j < 72 && windowWidth > 821) {
  42. numberOne.innerHTML = i;
  43. numberTwo.innerHTML = j;
  44. numberThree.innerHTML = k;
  45. } else {
  46. numberOne.innerHTML = 300;
  47. numberTwo.innerHTML = 99.999;
  48. numberThree.innerHTML = 300;
  49. clearInterval(rocketTimer)
  50. }
  51. }, 13);
  52. });
  53. //火箭下Din字体引入
  54. function loadDinFont(code) {
  55. var style = document.createElement('style');
  56. style.type = 'text/css';
  57. style.rel = 'stylesheet';
  58. try {
  59. //for Chrome Firefox Opera Safari
  60. style.appendChild(document.createTextNode(code));
  61. } catch (ex) {
  62. //for IE
  63. style.styleSheet.cssText = code;
  64. }
  65. var head = document.getElementsByTagName('head')[0];
  66. head.appendChild(style);
  67. }
  68. var DinFont = "@font-face{font-family:'dinregular';src:url('" + baseSite + "fonts/DIN-Regular.eot');src:url('" + baseSite + "fonts/DIN-Regular.eot?#iefix') format('embedded-opentype'),url('" + baseSite + "fonts/DIN-Regular.woff') format('woff'),url('" + baseSite + "fonts/DIN-Regular.ttf') format('truetype'),url('" + baseSite + "fonts/DIN-Regular.svg#dinregular') format('svg');}"
  69. loadDinFont(DinFont);
  70. // })