最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

vue原生滿屏滾動(dòng)方式

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

vue原生滿屏滾動(dòng)

vue原生滿屏滾動(dòng)效果,點(diǎn)擊左側(cè)導(dǎo)航欄可滾動(dòng)至對(duì)應(yīng)屏幕。

效果圖

代碼

<template>
  <div class='page-sum'>
    <div class='distance'>
      <!--      左側(cè)導(dǎo)航欄-->
      <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()  //整屏移動(dòng)
  },
  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)` //整屏上下移
      }
 
      // 劃分左側(cè)導(dǎo)航欄內(nèi)有幾屏
      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;
}
 
//滾動(dòng)條的寬度
::-webkit-scrollbar {
  width: 0.25rem;
  height: 0.25rem;
 
}
 
//滾動(dòng)條的設(shè)置
::-webkit-scrollbar-thumb {
  background-color: #ddd;
  background-clip: padding-box;
  min-height: 1.75rem;
}
</style>

總結(jié)

以上為個(gè)人經(jīng)驗(yàn),希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。

相關(guān)文章

  • 一個(gè)例子輕松學(xué)會(huì)Vue.js

    一個(gè)例子輕松學(xué)會(huì)Vue.js

    這篇文章主要為大家詳細(xì)介紹了一個(gè)例子,幫助大輕松學(xué)會(huì)Vue.js,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2017-01-01
  • 詳解Vue中的基本語法和常用指令

    詳解Vue中的基本語法和常用指令

    Vue.js 是一套構(gòu)建用戶界面的框架,**只關(guān)注視圖層**,它不僅易于上手,還便于與第三方庫或既有項(xiàng)目整合。這篇文章主要介紹了vue 的基本語法和常用指令,需要的朋友可以參考下
    2019-07-07
  • 一文徹底搞懂Vue的MVVM響應(yīng)式原理

    一文徹底搞懂Vue的MVVM響應(yīng)式原理

    這篇文章主要介紹了一文徹底搞懂Vue的MVVM響應(yīng)式原理,vue則是采用發(fā)布者-訂閱者模式,通過Object.defineProperty()來劫持各個(gè)屬性的getter和setter,在數(shù)據(jù)變動(dòng)時(shí)發(fā)布消息給訂閱者,觸發(fā)相應(yīng)的監(jiān)聽回調(diào)
    2022-06-06
  • Element實(shí)現(xiàn)表格分頁數(shù)據(jù)選擇+全選所有完善批量操作

    Element實(shí)現(xiàn)表格分頁數(shù)據(jù)選擇+全選所有完善批量操作

    這篇文章主要介紹了Element實(shí)現(xiàn)表格分頁數(shù)據(jù)選擇+全選所有完善批量操作,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家學(xué)習(xí)或者使用vue具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面來一起學(xué)習(xí)學(xué)習(xí)吧
    2019-06-06
  • vue中計(jì)算屬性computed理解說明包括vue偵聽器,緩存與computed的區(qū)別

    vue中計(jì)算屬性computed理解說明包括vue偵聽器,緩存與computed的區(qū)別

    這篇文章主要介紹了對(duì)vue中計(jì)算屬性computed理解說明包括vue偵聽器,緩存與computed的區(qū)別,需要的朋友可以參考下
    2022-05-05
  • Vue自定義指令深入探討實(shí)現(xiàn)

    Vue自定義指令深入探討實(shí)現(xiàn)

    這篇文章主要介紹了Vue自定義指令的實(shí)現(xiàn),Vue支持自定義指令,開發(fā)者可以根據(jù)自己的需求,創(chuàng)建自己的指令來擴(kuò)展Vue的功能,需要詳細(xì)了解可以參考下文
    2023-05-05
  • 在Vue3中創(chuàng)建和使用自定義指令的實(shí)現(xiàn)方式

    在Vue3中創(chuàng)建和使用自定義指令的實(shí)現(xiàn)方式

    在現(xiàn)代前端開發(fā)中,Vue.js 是一個(gè)非常流行的框架,它提供了許多強(qiáng)大的功能來幫助開發(fā)者構(gòu)建高效的用戶界面,自定義指令是 Vue.js 的一個(gè)重要特性,它允許開發(fā)者擴(kuò)展 HTML 元素的功能,本文將詳細(xì)介紹如何在 Vue3 中創(chuàng)建和使用自定義指令,并提供示例代碼來幫助理解
    2024-12-12
  • Vue精美簡潔登錄頁完整代碼實(shí)例

    Vue精美簡潔登錄頁完整代碼實(shí)例

    這篇文章主要給大家介紹了關(guān)于Vue精美簡潔登錄頁完整代碼的相關(guān)資料,通過文中的方法大家可以使用實(shí)現(xiàn)簡單的用戶登錄界面,下面通過示例代碼介紹的非常詳細(xì),需要的朋友可以參考下
    2023-07-07
  • 使用canvas實(shí)現(xiàn)一個(gè)vue彈幕組件功能

    使用canvas實(shí)現(xiàn)一個(gè)vue彈幕組件功能

    這篇文章主要介紹了使用canvas實(shí)現(xiàn)一個(gè)vue彈幕組件功能,非常不錯(cuò),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2018-11-11
  • Vue+Canvas繪圖使用的講解

    Vue+Canvas繪圖使用的講解

    這篇文章主要介紹了Vue+Canvas繪圖的使用方式,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2022-08-08

最新評(píng)論

阿巴嘎旗| 陆良县| 金华市| 丹寨县| 盐山县| 延吉市| 尼玛县| 九江市| 安新县| 台东市| 万宁市| 沙雅县| 湖口县| 柳州市| 绥芬河市| 兰溪市| 阳春市| 科技| 宝应县| 青阳县| 临汾市| 耿马| 科技| 高台县| 昔阳县| 尖扎县| 安多县| 樟树市| 澳门| 吉隆县| 广昌县| 本溪| 璧山县| 泊头市| 南丹县| 浦东新区| 开封县| 新绛县| 清丰县| 乐陵市| 合阳县|