欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

vue實(shí)現(xiàn)頁面加載動(dòng)畫效果

 更新時(shí)間:2017年09月19日 11:26:48   作者:gang456789  
這篇文章主要為大家詳細(xì)介紹了vue實(shí)現(xiàn)頁面加載動(dòng)畫效果,vue頁面出現(xiàn)正在加載的初始頁面與實(shí)現(xiàn)動(dòng)畫效果,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

我們經(jīng)??吹綌?shù)據(jù)未出現(xiàn)時(shí),頁面中會(huì)有一條提示消息, 頁面正在加載中,如何實(shí)現(xiàn)該效果呢 ,請(qǐng)看下面代碼

<template>
 <section class="page" v-if="option" 
  :style="{background: option.background,color: option.color||'#fff'}"  
  :class="{'page-before': option.index < currentPage,
    'page-after': option.index > currentPage,
    'page-current': option.index === currentPage}">
  <div :class="{'all-center': option.isCenter}">
   <slot></slot>
  </div>
 </section>
 <section class="page" v-else>頁面正在渲染中。。。</section>
</template>

有木有感覺很簡(jiǎn)單
下面上點(diǎn)干貨,實(shí)現(xiàn)頁面的動(dòng)畫效果

<template>
 <nav class="controller">
  <button v-if="option.arrowsType" class="prev-btn" :class="{moving:option.arrowsType === 'animate'}" @click="changePage(prevIndex)"></button>
  <ul v-if="option.navbar">
   <li v-for="index in pageNum" @click="changePage(index)" :class="{current:option.highlight && index === currentPage}" :key="'controller-'+index" :data-index="index" class="controller-item"></li>
  </ul>
  <button v-if="option.arrowsType" class="next-btn" :class="{moving:option.arrowsType === 'animate'}" @click="changePage(nextIndex)"></button>
 </nav>
</template>

<script>
export default {
 name: 'page-controller',
 props: {
 pageNum: Number,
 currentPage: Number,
 option: {
  type: Object,
  default: {
  arrowsType: 'animate',
  navbar: true,
  highlight: true,
  loop: true  //是否開啟滾動(dòng)循環(huán)
  }
 }
 },
 methods: {
 changePage (index) {
  this.$emit('changePage', index);
 }
 },
 computed: {
 nextIndex () {
  if (this.currentPage === this.pageNum) {
  if(this.option.loop){
   return 1
   }else{
   return this.pageNum
   }
  } else {
  return this.currentPage + 1;
  }
 },
 prevIndex () {
  if (this.currentPage === 1) {
  if(this.option.loop){
   return this.pageNum
   }else{
   return 1
   }
  } else {
  return this.currentPage - 1;
  }
 }
 },
 created () {
 if (this.option.navbar === undefined) {
  this.option.navbar = true;
 }
 },
 mounted () {
 let _this = this;
 let timer = null;
 let start = 0;
 // 滾輪處理
 function scrollHandler (direction) {
  // 防止重復(fù)觸發(fā)滾動(dòng)事件
  if (timer != null) {
  return;
  }
  if (direction === 'down') {
  _this.changePage(_this.nextIndex);
  } else {
  _this.changePage(_this.prevIndex);
  }
  timer = setTimeout(function() {
  clearTimeout(timer);
  timer = null;
  }, 300);
 }
 // if (Object.hasOwnProperty.call(window,'onmousewheel')) {
 if (Object.hasOwnProperty.call(window,'onmousewheel')) {
  // 監(jiān)聽滾輪事件
  window.addEventListener('mousewheel',function (event) { // IE/Opera/Chrome
  let direction = event.wheelDelta > 0 ? 'up':'down';
  scrollHandler(direction);
  },false);
 } else {
  window.addEventListener('DOMMouseScroll',function (event) { // Firefox
  let direction = event.detail > 0 ? 'up':'down';
  scrollHandler(direction);
  },false);
 }
 // 移動(dòng)端觸摸事件處理
 window.addEventListener('touchstart', function (event) {
  start = event.touches[0].clientY;
 })
 window.addEventListener('touchmove', function (event) {
  event.preventDefault();
 })
 window.addEventListener('touchend', function (event) {
  let spacing = event.changedTouches[0].clientY - start;
  let direction;  
  if (spacing > 50) {
  direction = 'up';
  scrollHandler(direction);
  } else if (spacing < -50) {
  direction = 'down';
  scrollHandler(direction);
  }
 })
 }
}
</script>

<style scoped>
.controller {
 position: fixed;
 right: 20px;
 top: 50%;
 z-index: 99;
}
.controller ul {
 transform: translate3d(0,-50%,0);
 list-style: none;
 margin: 0;
 padding: 0;
}
.controller-item {
 cursor: pointer;
 width: 20px;
 height: 20px;
 border-radius: 50%;
 margin-top: 10px;
 background-color: rgba(255, 255, 255, 0.3);
 transition: background-color 0.3s ease 0s;
}
.controller-item:hover {
 background-color: rgba(255, 255, 255, 0.7);
}
.controller-item.current {
 background-color: rgba(255, 255, 255, 1);
}
.prev-btn,.next-btn {
 cursor: pointer;
 display: block;
 text-align: center;
 width: 20px;
 height: 20px;
 position: fixed;
 left: 50%;
 margin-left: -10px;
 border: 4px solid #fff;
 background-color: transparent;
 outline: none;
}
.prev-btn {
 top: 80px;
 transform: rotate(-45deg);
 border-bottom-color: transparent;
 border-left-color: transparent;
}
.next-btn {
 bottom: 80px;
 transform: rotate(45deg);
 border-top-color: transparent;
 border-left-color: transparent;
}
.prev-btn.moving {
 animation: prev-up-down 0.7s linear 0s infinite;
}
.next-btn.moving {
 animation: next-up-down 0.7s linear 0s infinite;
}
@keyframes next-up-down {
 0% {
 transform: translate3d(0,0,0) rotate(45deg);
 }
 25% {
 transform: translate3d(0,6px,0) rotate(45deg);
 }
 50% {
 transform: translate3d(0,0,0) rotate(45deg);
 }
 75% {
 transform: translate3d(0,-6px,0) rotate(45deg);
 }
 100% {
 transform: translate3d(0,0,0) rotate(45deg);
 }
}
@keyframes prev-up-down {
 0% {
 transform: translate3d(0,0,0) rotate(-45deg);
 }
 25% {
 transform: translate3d(0,-6px,0) rotate(-45deg);
 }
 50% {
 transform: translate3d(0,0,0) rotate(-45deg);
 }
 75% {
 transform: translate3d(0,6px,0) rotate(-45deg);
 }
 100% {
 transform: translate3d(0,0,0) rotate(-45deg);
 }
}
</style>

本文已被整理到了《Vue.js前端組件學(xué)習(xí)教程》,歡迎大家學(xué)習(xí)閱讀。

關(guān)于vue.js組件的教程,請(qǐng)大家點(diǎn)擊專題vue.js組件學(xué)習(xí)教程進(jìn)行學(xué)習(xí)。

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • 在vue中使用eslint,配合vscode的操作

    在vue中使用eslint,配合vscode的操作

    這篇文章主要介紹了在vue中使用eslint,配合vscode的操作,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧
    2020-11-11
  • vue uniapp 防止按鈕多次點(diǎn)擊的三種實(shí)現(xiàn)方式

    vue uniapp 防止按鈕多次點(diǎn)擊的三種實(shí)現(xiàn)方式

    最近的項(xiàng)目完成后,在性能優(yōu)化階段需要做按鈕的防止重復(fù)點(diǎn)擊功能,本文主要介紹了vue uniapp 防止按鈕多次點(diǎn)擊的三種實(shí)現(xiàn)方式,具有一定的參考價(jià)值,感興趣的可以了解一下
    2023-08-08
  • 詳解Vue2.0之去掉組件click事件的native修飾

    詳解Vue2.0之去掉組件click事件的native修飾

    這篇文章主要介紹了詳解Vue2.0之去掉組件click事件的native修飾,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧
    2017-04-04
  • Vue常用指令v-if與v-show的區(qū)別淺析

    Vue常用指令v-if與v-show的區(qū)別淺析

    v-if和v-show的區(qū)別是前端面試中常問的基礎(chǔ)知識(shí)點(diǎn),v-if、v-show顧名思義就是用來判斷視圖層展示效果的,下面這篇文章主要給大家介紹了關(guān)于Vue常用指令v-if與v-show區(qū)別的相關(guān)資料,需要的朋友可以參考下
    2021-10-10
  • vue3?reactive響應(yīng)式依賴收集派發(fā)更新原理解析

    vue3?reactive響應(yīng)式依賴收集派發(fā)更新原理解析

    這篇文章主要為大家介紹了vue3響應(yīng)式reactive依賴收集派發(fā)更新原理解析,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2023-03-03
  • Vue?2?和?Vue?3?中?toRefs函數(shù)的不用用法

    Vue?2?和?Vue?3?中?toRefs函數(shù)的不用用法

    Vue?是一款流行的JavaScript?框架,用于構(gòu)建用戶界面,在Vue2和?Vue3中,都存在一個(gè)名為toRefs的函數(shù),但其行為在這兩個(gè)版本中有所不同,這篇文章主要介紹了Vue2和Vue3中toRefs的區(qū)別,需要的朋友可以參考下
    2023-08-08
  • Vue中子組件不能修改父組件傳來的Prop值的原因分析

    Vue中子組件不能修改父組件傳來的Prop值的原因分析

    在Vue中,父子組件之間通過Prop和Event實(shí)現(xiàn)了數(shù)據(jù)的雙向綁定,但是,Vue設(shè)計(jì)者為什么不允許子組件修改父組件傳遞的Prop呢,本文就來帶大家探究為什么子組件不能修改Prop,需要的朋友可以參考下
    2023-06-06
  • Vue中事件總線(eventBus)的深入詳解及使用

    Vue中事件總線(eventBus)的深入詳解及使用

    在vue項(xiàng)目中父子組件間的通訊很方便,但兄弟組件或多層嵌套組件間的通訊,就會(huì)比較麻煩,這時(shí)使用eventBus通訊,就可以很便捷的解決這個(gè)問題,這篇文章主要給大家介紹了關(guān)于Vue中事件總線(eventBus)使用的相關(guān)資料,需要的朋友可以參考下
    2022-03-03
  • vue.js聲明式渲染和條件與循環(huán)基礎(chǔ)知識(shí)

    vue.js聲明式渲染和條件與循環(huán)基礎(chǔ)知識(shí)

    這篇文章主要為大家詳細(xì)介紹了vue.js聲明式渲染和條件與循環(huán)的基礎(chǔ)知識(shí),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2017-07-07
  • Vue如何設(shè)置el-table背景透明樣式

    Vue如何設(shè)置el-table背景透明樣式

    本文主要介紹了Vue如何設(shè)置el-table背景透明樣式,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2022-08-08

最新評(píng)論