소스 검색

detectDirectino

huaisianhuang 3 년 전
부모
커밋
5f34912de8
1개의 변경된 파일12개의 추가작업 그리고 19개의 파일을 삭제
  1. 12 19
      js/index.js

+ 12 - 19
js/index.js

@@ -2,26 +2,18 @@
   /* if(screen.width >= 901){
       window.location.href = "https://www2.hhh.com.tw/";   
   } */
-  
-    let height = (window.screen.width * 2) / 3;
-    console.log(height);
-    $('.sec-02 .slide-item').css('height', `${height}px`);
-    let topHeight = (window.screen.width * 30) / 131;
-    console.log(topHeight);
-    $('.sec-00 .slide-item').css('height', `${topHeight}px`);
-    $('.sec-00 .container-fluid').css('height', `${topHeight}px`);
-  
-} 
-
-/* window.addEventListener('resize', reportWindowSize);
+  detectDirection ()
+}
 
-function reportWindowSize() {
-  if(screen.width > 480) {
-    $('.sec-02 .slide-item').css('height', `130vh`);
-    $('.sec-00 .slide-item').css('height', `200px`);
-    $('.sec-00 .container-fluid').css('height', `200px`);
-  }
-} */
+function detectDirection () {
+  let height = (window.screen.width * 2) / 3;
+  console.log(height);
+  $('.sec-02 .slide-item').css('height', `${height}px`);
+  let topHeight = (window.screen.width * 30) / 131;
+  console.log(topHeight);
+  $('.sec-00 .slide-item').css('height', `${topHeight}px`);
+  $('.sec-00 .container-fluid').css('height', `${topHeight}px`);
+}
 
 $(".sec-01__slider").slick({
         dots: true,
@@ -331,6 +323,7 @@ $(".sec-01__slider").slick({
     const navbar = document.querySelector('.navbar-main');
     
     function fixedOnScroll() {
+      detectDirection ();
       const sticky = document.querySelector('.sec-00 .container-fluid').offsetHeight;
         if(window.pageYOffset >= sticky){
             navbar.classList.add('sticky');