goto.js 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. // 手機板menu彈跳視窗
  2. $("#menu-box2").hide();
  3. $("#menu-box").hide();
  4. $(".link").click(function () {
  5. $("#menu-box").fadeOut("slow", function () {
  6. $("#menu-box2").fadeOut("slow");
  7. // Animation complete.
  8. });
  9. });
  10. $("#menu-btn1").click(function () {
  11. $("#menu-box").fadeIn();
  12. $("#menu-box2").fadeIn();
  13. });
  14. $(".close").click(function () {
  15. $("#menu-box").fadeOut();
  16. $("#menu-box2").fadeOut();
  17. });
  18. // sec01 最新課程手機輪播
  19. $('#sec01-moblie-container').slick({
  20. arrows: false,
  21. slidesToShow: 1,
  22. slidesToScroll: 1,
  23. infinite: false,
  24. centerMode: true,
  25. });
  26. $('#sec01-slider-next').click(function () {
  27. $('#sec01-moblie-container').slick('slickNext')
  28. });
  29. // sec04 專欄報導 手機輪播
  30. $('#sec04-moblie-container').slick({
  31. arrows: false,
  32. slidesToShow: 1,
  33. slidesToScroll: 1,
  34. infinite: false,
  35. centerMode: true,
  36. });
  37. $('#sec04-slider-next').click(function () {
  38. $('#sec04-moblie-container').slick('slickNext')
  39. });
  40. // sec03排名table輪播
  41. $('#sec03-slider').slick({
  42. arrows: false,
  43. slidesToShow: 1,
  44. slidesToScroll: 1,
  45. infinite: true,
  46. });
  47. $('#sec03-slider-next').click(function () {
  48. $('#sec03-slider').slick('slickNext')
  49. });
  50. $("*").each(function (index, element) {
  51. // 此元素被點選後執行
  52. $(this).click(function (e) {
  53. // 取得被點選元素的屬性:data-gt-target
  54. var target = $(this).attr("data-gt-target");
  55. var duration = $(this).attr("data-gt-duration");
  56. var offset = $(this).attr("data-gt-offset");
  57. // JS 語法:判斷式
  58. // if (條件) {程式區塊}
  59. // 當條件成立,會執行程式區塊
  60. // 如果 目標有資料 才會執行 { } 內的程式
  61. // 避免出現 undefine (未定義 - 不存在的資料)
  62. if (target) {
  63. //console.log("目標:" + target);
  64. //console.log("時間:" + duration);
  65. //console.log("位移:" + offset);
  66. // 上方位置 = 目標區塊.位移().上方位置
  67. var top = $(target).offset().top;
  68. //console.log("要前往元素的上方位置:" + top);
  69. // 網頁元素.停止().動畫({ 上方捲動:指定元素 - 位移},持續時間)
  70. // parseInt() 將文字轉為數字
  71. $("html").stop().animate({
  72. scrollTop: top - offset
  73. }, parseInt(duration));
  74. }
  75. });
  76. });
  77. // 避免動畫與使用者滾輪衝突
  78. // html 在滾動滾輪時 停止 html 所有效果
  79. $("html").on("mousewheel", function () {
  80. $("html").stop();
  81. });