亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

vue原生滿屏滾動方式

 更新時間:2024年08月28日 09:00:29   作者:zyy_wx  
這篇文章主要介紹了vue原生滿屏滾動方式,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教

vue原生滿屏滾動

vue原生滿屏滾動效果,點擊左側導航欄可滾動至對應屏幕。

效果圖

代碼

<template>
  <div class='page-sum'>
    <div class='distance'>
      <!--      左側導航欄-->
      <div class='page-nav'>
        <div>
          <div @click='scrollByIndex(0)' class='nav-type'>
            <p :style="navIndex===0?'color:#00D2C7':''">企業(yè)主頁</p>
          </div>
          <div @click='scrollByIndex(4)' class='nav-type'>
            <p :style="navIndex===1?'color:#00D2C7':''">案例中心</p>
          </div>
          <div @click='scrollByIndex(5)' class='nav-type'>
            <p :style="navIndex===2?'color:#00D2C7':''">方案中心</p>
          </div>
          <div @click='scrollByIndex(7)' class='nav-type'>
            <p :style="navIndex===3?'color:#00D2C7':''">咨訊庫</p>
          </div>
          <div @click='scrollByIndex(9)' class='nav-type'>
            <p :style="navIndex===4?'color:#00D2C7':''">文檔庫</p>
          </div>
        </div>
      </div>
      <div class='page-box'>
        <div class='page-one' style='background: #5daf34'>
          第一頁
        </div>
        <div class='page-two' style='background: #1b8bff'>
          第二頁
        </div>
 
        <div class='page-three' style='background: #00a2d4'>
          第三頁11
        </div>
        <div class='page-four' style='background: #fab6b6'>
          第三頁22
        </div>
 
        <div class='page-five' style='background: #00DECB'>
          第四頁
        </div>
 
        <div class='page-six' style='background: #00D2C7'>
          第五頁11
        </div>
 
        <div class='page-seven' style='background: #2D64B3'>
          第五頁22
        </div>
        <div class='page-eight' style='background: #fab6b6'>
          第六頁11
        </div>
 
        <div class='page-nine' style='background: #00DECB'>
          第六頁22
        </div>
 
        <div class='page-ten' style='background: #00b7ee'>
          第七頁
        </div>
 
      </div>
    </div>
  </div>
</template>
<script>
 
export default {
  name: 'index',
  data() {
    return {
      navIndex: 0,
      wheel: 0,
      style: ''
    }
  },
  mounted() {
    this.initWheel()  //整屏移動
  },
  watch: {
    wheel: {
      handler(val) {
      }
    }
  },
  methods: {
    initWheel() {
      this.wheel = 0   //  0 到 10
      let timer = 1500
      let agent = navigator.userAgent.toLowerCase()
      let isMac = /macintosh|mac os x/i.test(navigator.userAgent)
      if (agent.indexOf('win32') >= 0 || agent.indexOf('wow32') >= 0 || agent.indexOf('win64') >= 0 || agent.indexOf('wow64') >= 0) {
        timer = 1000
      }
      if (isMac) {
        timer = 1500
      }
      window.addEventListener('wheel', this.throttle(this.wheelHandler, timer))  //兼容mac的方法  1500  timer  windows  為1000  mac為1500
    },
    throttle(func, delay) {
      let prev = Date.now()
      return function() {
        let context = this
        let args = arguments
        let now = Date.now()
        if (now - prev >= delay) {
          func.apply(context, args)
          prev = Date.now()
        }
      }
    },
    wheelHandler(e) {
      let main = document.querySelector('.page-box')
      let headHeight = document.querySelector('.page-one').clientHeight
      if (e.deltaY > 0) {
        if (this.wheel === 9) return
        this.wheel++
      } else {
        if (this.wheel === 0) return
        this.wheel--
      }
      if (this.wheel === 0) {
        main.style.transform = `translateY(0)` //整屏上下移
      } else {
        main.style.transform = `translateY(calc(-${headHeight}px - ${(this.wheel - 1) * 100}vh)` //整屏上下移
      }
 
      // 劃分左側導航欄內有幾屏
      if (this.wheel >= 0 && this.wheel < 4) { // 0 4 6 8
        this.navIndex = 0
      } else if (this.wheel >= 4 && this.wheel < 5) {
        this.navIndex = 1
      } else if (this.wheel >= 5 && this.wheel < 7) {
        this.navIndex = 2
      } else if (this.wheel < 9) {
        this.navIndex = 3
      } else if (this.wheel === 9) {
        this.navIndex = 4
      }
    },
    scrollByIndex(index) {
      let e = {
        deltaY: 100
      }
      this.wheel = index - 1
      this.wheelHandler(e)
    }
  }
}
</script>
 
<style lang='scss' scoped>
.page-sum {
  width: 100%;
  height: 100vh;
  overflow: hidden;
  position: relative;
}
 
.distance {
  width: 75rem;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
}
 
.page-box {
  width: 65.625rem;
  transform: translateY(0);
  transition: 1s;
}
 
.page-one {
  height: 100vh;
  position: relative;
  overflow: hidden;
}
 
.page-two {
  height: 100vh;
}
 
.page-three, .page-four {
  height: 100vh;
}
 
.page-five {
  height: 100vh;
}
 
.page-six {
  height: 100vh;
}
 
.page-seven {
  height: 100vh;
}
 
.page-eight {
  background: #fff;
  height: 100vh;
}
 
.page-nine {
  width: 100%;
  height: 100vh;
}
 
.page-ten {
  height: 100vh;
}
 
.page-nav {
  transform: translateY(50%);
  width: 8rem;
  height: 22rem;
  text-align: center;
  border-radius: 0.125rem;
  background: #FFF;
  box-shadow: 2px 1px 8px 1px rgba(208, 208, 208, 0.16);
}
 
.nav-type {
  cursor: pointer;
  font-size: 1rem;
  font-weight: 400;
  line-height: 3rem;
  color: #323232;
}
 
//滾動條的寬度
::-webkit-scrollbar {
  width: 0.25rem;
  height: 0.25rem;
 
}
 
//滾動條的設置
::-webkit-scrollbar-thumb {
  background-color: #ddd;
  background-clip: padding-box;
  min-height: 1.75rem;
}
</style>

總結

以上為個人經驗,希望能給大家一個參考,也希望大家多多支持腳本之家。

相關文章

  • vue 對axios get pust put delete封裝的實例代碼

    vue 對axios get pust put delete封裝的實例代碼

    在本篇文章里我們給各位整理的是一篇關于vue 對axios get pust put delete封裝的實例代碼內容,有需要的朋友們可以參考下。
    2020-01-01
  • Vue3實現常見附件的預覽功能

    Vue3實現常見附件的預覽功能

    最近開發(fā)了一個建筑相關的移動端項目,其中有各種附件預覽的功能,本文總結出了一些Vue常用的文件預覽方式,希望對大家有一定的幫助
    2025-04-04
  • vue路由跳轉后刷新指定頁面的方法

    vue路由跳轉后刷新指定頁面的方法

    這篇文章主要介紹了vue路由跳轉后刷新指定頁面的方法,本文給大家介紹的非常詳細,對大家的學習或工作具有一定的參考借鑒價值,需要的朋友可以參考下
    2022-12-12
  • VueJs中如何使用Teleport及組件嵌套層次結構詳解

    VueJs中如何使用Teleport及組件嵌套層次結構詳解

    這篇文章主要為大家介紹了VueJs中如何使用Teleport及組件嵌套層次結構詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步,早日升職加薪
    2023-04-04
  • Vue使用jsmind實現生成腦圖的示例代碼

    Vue使用jsmind實現生成腦圖的示例代碼

    這篇文章主要為大家詳細介紹了Vue如何使用jsmind實現生成腦圖,文中的示例代碼講解詳細,具有一定的借鑒價值,有需要的小伙伴可以參考一下
    2024-03-03
  • VUE3 加載自定義SVG文件的詳細步驟

    VUE3 加載自定義SVG文件的詳細步驟

    要在 Vue 項目中使用 svg-sprite-loader 來管理 SVG 圖標,需要執(zhí)行相應的步驟,接下來通過本文給大家介紹VUE3 加載自定義SVG文件的詳細步驟,感興趣的朋友一起看看吧
    2024-01-01
  • django使用channels2.x實現實時通訊

    django使用channels2.x實現實時通訊

    這篇文章主要介紹了django使用channels2.x實現實時通訊,小編覺得挺不錯的,現在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2018-11-11
  • Vue2.X 通過AJAX動態(tài)更新數據

    Vue2.X 通過AJAX動態(tài)更新數據

    這篇文章主要介紹了Vue2.X 通過AJAX動態(tài)更新數據的方法,非常不錯,具有一定的參考借鑒價值,需要的朋友可以參考下
    2018-07-07
  • Vue中的 DOM與Diff詳情

    Vue中的 DOM與Diff詳情

    這篇文章主要介紹了Vue中的 DOM與Diff詳情,文章圍繞主題展開詳細的內容介紹,具有一定的參考價值,感興趣的小伙伴可以參考一下,希望對你的學習有所幫助
    2022-08-08
  • vue使用pdfjs-dist+fabric實現pdf電子簽章的思路詳解

    vue使用pdfjs-dist+fabric實現pdf電子簽章的思路詳解

    最近領導提了一個新需求:仿照e簽寶,實現pdf電子簽章,本文給大家介紹vue使用pdfjs-dist+fabric實現pdf電子簽章的思路,感興趣的朋友一起看看吧
    2023-12-12

最新評論