zoukankan      html  css  js  c++  java
  • vue 列表上下无缝滚动轮播

    vue 列表上下无缝滚动轮播

    滚动从头到尾从上到下,最后首位相接,无限滚动

     // 判断是否滚动
        setTopGoBom() {
          let dom = this.$refs[this.bodyTableId];
          if (dom) {
            let allH = dom.offsetHeight;
            let chiDom = dom.firstElementChild;
            let chiLength = dom.children.length;
            let chiH = 0;
            let chiAllH = 0;
            if (chiDom) {
              chiH = chiDom.offsetHeight;
              chiAllH = chiH * chiLength;
              if (chiAllH > allH) {
                this.stateScorl(dom, chiDom);
              }
            }
          }
        },
        // 开始滚动
        stateScorl(dom, chiDom) {
          let _this = this;
          let timePop = 1;
          let offPop = this.resultNumRun;
          let chiLength = dom.children.length;
          let chiH = chiDom.offsetHeight;
          let allH = dom.offsetHeight;
          let chiAllH = chiH * chiLength;
          if (this.timeScorl) {
            clearInterval(this.timeScorl);
          }
          let resultH = 0;
          let chazhi = chiAllH - allH;
          this.timeScorl = setInterval(scorlRun, timePop);
          // 滚动方式
          function scorlRun() {
            if (chazhi > resultH) {
              resultH = resultH + offPop;
              if (resultH > chiH) {
                if (_this.timeScorl) {
                  clearInterval(_this.timeScorl);
                }
    // 获取隐藏消失的dom let fistnode
    = dom.firstElementChild;
    // 删除dom dom.removeChild(fistnode);
    // 放到队尾 dom.appendChild(fistnode); resultH
    = 0; if (this.timeScorl1) { clearTimeout(this.timeScorl1); } _this.timeScorl1 = setTimeout(function() { _this.timeScorl = setInterval(scorlRun, timePop); }, 1000); } else { setScrollTop(dom, resultH); } } else { if (this.timeScorl1) { clearTimeout(this.timeScorl1); } if (_this.timeScorl) { clearInterval(_this.timeScorl); } } } //设置窗口滚动条高度 function setScrollTop(domIn, top) { if (!isNaN(top)) domIn.scrollTop = top; } },
    转载标明来路-博客园, 联系方式1763907618@qq.com
  • 相关阅读:
    精妙Sql语句
    TSQL是否有循环语句?类似C语言的for?如何查看有哪些用户连接到服务器上?如何强制其退出?
    Tools1.4
    Set Up1.2
    Getting Started1.0
    Start Developing iOS Apps Today1.1
    Language1.5
    Jump Right In1.3
    编译器错误信息: CS0246: 找不到类型或命名空间名称“Discuz”(是否缺少 using 指令或程序集引用?)
    ashx文件无法访问
  • 原文地址:https://www.cnblogs.com/wangyongping/p/15766882.html
Copyright © 2011-2022 走看看