const status = [
        "position:absolute;left:804px;top:155px;width:210.008px;height:243.418px;opacity:0.43;z-index:82;font-size:6.9px;",
        "position:absolute;left:492px;top:221px;width:97.6712px;height:113.21px;opacity:0.2;z-index:1;font-size:3.2px;",
        "position:absolute;left:40px;top:174px;width:178.064px;height:206.392px;opacity:0.37;z-index:59;font-size:5.9px;",
        "position: absolute; left: -99px; top: 62px; width: 370.792px; height: 429.782px; opacity: 0.77; z-index: 198; font-size: 12.3px;",
        "position: absolute; left: 213px; top: -3px; width: 483.129px; height: 559.99px; opacity: 1; z-index: 279; font-size: 16px;",
        "position: absolute; left: 665px; top: 44px; width: 402.736px; height: 466.808px; opacity: 0.83; z-index: 221; font-size: 13.3px;",
      ];

      function swiper(status, list, leftBtn, rightBtn) {
        var index = 0;
        var arr = document.querySelectorAll(list);
        function act(direction) {
          index = range(direction ? index - 1 : index + 1, arr.length - 1, 0);
          for (let i = 0; i < arr.length; i++) {
            arr[i].setAttribute("style", status[(index + i) % status.length]);
          }
        }

        function range(num, max, min) {
          return num > max ? min : num < min ? max : num;
        }

        document.querySelector(leftBtn).onclick = function () {
          act(false);
        };
        document.querySelector(rightBtn).onclick = function () {
          act(true);
        };
        setInterval(() => {
          act(true);
        }, 2000);
      }

      swiper(status, ".swiperBox > li", ".move_lefts", ".move_rights");

 

 posted on 2023-11-23 10:35  laremehpe  阅读(3)  评论(0编辑  收藏  举报