goto.js 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. $(".banner-slider").slick({
  2. speed: 1000,
  3. swipe: true,
  4. arrows:false,
  5. });
  6. $(".content1-right").slick({
  7. dotsClass: 'slick-dots',
  8. dots: true,
  9. speed: 1000,
  10. arrows:false,
  11. });
  12. // banner輪播效果
  13. // $(".banner-slider").on('beforeChange', function (event, slick, currentSlide, nextSlide) {
  14. // console.log('beforeChangeEvent: currenSlide=' + currentSlide + ', nextSlide= ' + nextSlide);
  15. // if (nextSlide == 1) {
  16. // $("#animation2").addClass("animation-h1");
  17. // $("#btn-animation2").addClass("animation-btn");
  18. // $("#animation1").removeClass("animation-h1");
  19. // $("#btn-animation1").removeClass("animation-btn");
  20. // $("#animation3").removeClass("animation-h1");
  21. // $("#btn-animation3").removeClass("animation-btn");
  22. // }
  23. // else if (nextSlide == 2) {
  24. // $("#animation3").addClass("animation-h1");
  25. // $("#btn-animation3").addClass("animation-btn");
  26. // $("#animation1").removeClass("animation-h1");
  27. // $("#btn-animation1").removeClass("animation-btn");
  28. // $("#animation2").removeClass("animation-h1");
  29. // $("#btn-animation2").removeClass("animation-btn");
  30. // }else if (nextSlide == 0) {
  31. // $("#animation1").addClass("animation-h1");
  32. // $("#btn-animation1").addClass("animation-btn");
  33. // $("#animation2").removeClass("animation-h1");
  34. // $("#btn-animation2").removeClass("animation-btn");
  35. // $("#animation3").removeClass("animation-h1");
  36. // $("#btn-animation3").removeClass("animation-btn");
  37. // }
  38. // });
  39. // content輪播圖片偵測效果
  40. $(".text-1").addClass("contant-toggle");
  41. $(".content1-right").on('beforeChange', function (event, slick, currentSlide, nextSlide) {
  42. console.log('beforeChangeEvent: currenSlide=' + currentSlide + ', nextSlide= ' + nextSlide);
  43. if (nextSlide == 1) {
  44. $(".text-1").removeClass("contant-toggle");
  45. $(".text-2").addClass("contant-toggle");
  46. $(".text-3").removeClass("contant-toggle");
  47. } else if (nextSlide == 2) {
  48. $(".text-2").removeClass("contant-toggle");
  49. $(".text-1").removeClass("contant-toggle");
  50. $(".text-3").addClass("contant-toggle");
  51. } else if (nextSlide == 0) {
  52. $(".text-2").removeClass("contant-toggle");
  53. $(".text-1").addClass("contant-toggle");
  54. $(".text-3").removeClass("contant-toggle");
  55. }
  56. });
  57. $("#contact-form").submit(function (e) {
  58. var param_string = $('#contact-form').serialize();
  59. alert('param_string = ' + param_string);
  60. $.ajax({
  61. type: 'GET',
  62. url: 'http://172.104.93.163/deco_request_detail',
  63. data: param_string,
  64. dataType: 'json',
  65. success: function (data, textStatus, jqXHR) {
  66. alert("送出成功");
  67. },
  68. beforeSend: function () {
  69. alert("beforeSend");
  70. },
  71. complete: function () {
  72. alert("complete");
  73. },
  74. error: function (jqXHR, textStatus, errorThrown) {
  75. alert("送出失敗");
  76. }
  77. });
  78. return false;
  79. });
  80. $("*").each(function (index, element) {
  81. // 此元素被點選後執行
  82. $(this).click(function (e) {
  83. // 取得被點選元素的屬性:data-gt-target
  84. var target = $(this).attr("data-gt-target");
  85. var duration = $(this).attr("data-gt-duration");
  86. var offset = $(this).attr("data-gt-offset");
  87. // JS 語法:判斷式
  88. // if (條件) {程式區塊}
  89. // 當條件成立,會執行程式區塊
  90. // 如果 目標有資料 才會執行 { } 內的程式
  91. // 避免出現 undefine (未定義 - 不存在的資料)
  92. if (target) {
  93. //console.log("目標:" + target);
  94. //console.log("時間:" + duration);
  95. //console.log("位移:" + offset);
  96. // 上方位置 = 目標區塊.位移().上方位置
  97. var top = $(target).offset().top;
  98. //console.log("要前往元素的上方位置:" + top);
  99. // 網頁元素.停止().動畫({ 上方捲動:指定元素 - 位移},持續時間)
  100. // parseInt() 將文字轉為數字
  101. $("html").stop().animate({
  102. scrollTop: top - offset
  103. }, parseInt(duration));
  104. }
  105. });
  106. });
  107. // 避免動畫與使用者滾輪衝突
  108. // html 在滾動滾輪時 停止 html 所有效果
  109. $("html").on("mousewheel", function () {
  110. $("html").stop();
  111. });