$(window).bind('scroll', function (e) { parallaxScroll(); }); function parallaxScroll() { var scrolled = $(window).scrollTop(); $('#act1').css('top', (30 + (scrolled * .1)) + 'px'); $('#act2').css('top', (800 - (scrolled * .2)) + 'px'); $('#act3').css('top', (300 - (scrolled * .1)) + 'px'); $('#act4').css('top', (0 + (scrolled * .1)) + 'px'); $('#act5').css('top', (800 - (scrolled * .2)) + 'px'); } // 手機課程大綱輪播 $("#card-box").slick({ arrows: false, slidesToShow: 1, centerMode: true, infinite: false, }); // 手機課程大綱彈跳視窗 // 視窗一 $(".box-img01").click(function () { $(".mobile01-1").fadeIn(); $(".mobile-box1").fadeIn(); $(".card-box-1").slick({ arrows: false, slidesToShow: 1, centerMode: true, infinite: false, }); }); $(".close").click(function () { $(".mobile-box1").fadeOut(); $(".mobile01-1").fadeOut(); }); // 視窗二 $(".mobile01-2").fadeOut(0); $(".mobile-box2").fadeOut(0); $(".box-img02").click(function() { $(".mobile01-2").fadeIn(); $(".mobile-box2").fadeIn(); $(".card-box-2").slick({ arrows: false, slidesToShow: 1, centerMode: true, infinite: false, }); }); $(".close").click(function(){ $(".mobile-box2").fadeOut(); $(".mobile01-2").fadeOut(); }); // 視窗三 $(".mobile01-3").fadeOut(0); $(".mobile-box3").fadeOut(0); $(".box-img03").click(function() { $(".mobile01-3").fadeIn(); $(".mobile-box3").fadeIn(); $(".card-box-3").slick({ arrows: false, slidesToShow: 1, centerMode: true, infinite: false, }); }); $(".close").click(function(){ $(".mobile-box3").fadeOut(); $(".mobile01-3").fadeOut(); }); // 手機課程日程輪播 $("#card-box2").slick({ arrows: false, slidesToShow: 1, centerMode: true, infinite: false, }); // 手機選單彈跳視窗 $("#menu-box2").hide(); $("#menu-box").hide(); $("#menu-btn1").click(function () { $("#menu-box").slideToggle("slow"); $("#menu-box2").slideToggle("slow"); }); $(".link").click(function () { $("#menu-box").slideUp("slow", function () { $("#menu-box2").slideUp("slow"); // Animation complete. }); }); $("*").each(function (index, element) { // 此元素被點選後執行 $(this).click(function (e) { // 取得被點選元素的屬性:data-gt-target var target = $(this).attr("data-gt-target"); var duration = $(this).attr("data-gt-duration"); var offset = $(this).attr("data-gt-offset"); // JS 語法:判斷式 // if (條件) {程式區塊} // 當條件成立,會執行程式區塊 // 如果 目標有資料 才會執行 { } 內的程式 // 避免出現 undefine (未定義 - 不存在的資料) if (target) { //console.log("目標:" + target); //console.log("時間:" + duration); //console.log("位移:" + offset); // 上方位置 = 目標區塊.位移().上方位置 var top = $(target).offset().top; //console.log("要前往元素的上方位置:" + top); // 網頁元素.停止().動畫({ 上方捲動:指定元素 - 位移},持續時間) // parseInt() 將文字轉為數字 $("html").stop().animate({ scrollTop: top - offset }, parseInt(duration)); } }); }); // 避免動畫與使用者滾輪衝突 // html 在滾動滾輪時 停止 html 所有效果 $("html").on("mousewheel", function () { $("html").stop(); }); $(".arrow").hide(); $(window).scroll(function () { var y = window.scrollY; if (y > 10) { $(".arrow").show(); } else { $(".arrow").hide(); } });