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

Vue實(shí)現(xiàn)回到頂部和底部動(dòng)畫(huà)效果

 更新時(shí)間:2019年07月31日 16:03:11   作者:zzh1918  
這篇文章主要為大家詳細(xì)介紹了Vue實(shí)現(xiàn)回到頂部和底部動(dòng)畫(huà)效果,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

本文實(shí)例為大家分享了Vue實(shí)現(xiàn)回到頂部和底部動(dòng)畫(huà)效果的具體代碼,供大家參考,具體內(nèi)容如下

代碼:

<template>
 <div>
  <div class="scroll" :class="{show:isActive}">
   <div id="toTop" @click="toTop(step)">&lt;</div>
   <div id="toBottom" @click="toBottom(step)">&gt;</div>
  </div>
 </div>
</template>
<script>
 export default{
  props:{
   step:{ //此數(shù)據(jù)是控制動(dòng)畫(huà)快慢的
    type:Number,
    default:50 
   }
  },
  data(){
   return {
    isActive:false,
   }
  },
  methods:{
   toTop(i){
    //參數(shù)i表示間隔的幅度大小,以此來(lái)控制速度
    document.documentElement.scrollTop-=i;
    if (document.documentElement.scrollTop>0) {
     var c=setTimeout(()=>this.toTop(i),16);
    }else {
     clearTimeout(c);
    }
   },
   toBottom(i){
    var clientHeight=document.documentElement.clientHeight||document.body.clientHeight;
    var scrollHeight=document.documentElement.scrollHeight;
    var height=scrollHeight-clientHeight; //超出窗口上界的值就是底部的scrolTop的值
    document.documentElement.scrollTop+=i;
    if (document.documentElement.scrollTop<height) {
     var c=setTimeout(()=>this.toBottom(i),16);
    }else {
     clearTimeout(c);
    }
   }
  },
  created(){
   var vm=this;
   window.οnscrοll=function(){
    if (document.documentElement.scrollTop>60) {
     vm.isActive=true;
    }else {
     vm.isActive=false;
    }
   }
  }
 }
</script>
<style scoped>
 .scroll{
   position: fixed;
   right: 10px;
   bottom: 60px;
   width: 45px;
   height: 90px;
   cursor: pointer;
   display: none;
  }
  .scroll>div{
   width: 45px;
   height: 45px;
   transform: rotate(90deg);
   line-height: 45px;
   text-align: center;
   font-size: 35px;
   font-family: "黑體";
   background-color: rgba(0,0,0,.2);
   color: #fff;
  }
  .scroll>div:hover{
   background-color: rgba(0,0,0,.5);
  }
  .show{
   display: block;
  }
</style>

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

相關(guān)文章

最新評(píng)論

团风县| 讷河市| 井陉县| 罗山县| 彭山县| 绵竹市| 富源县| 小金县| 宿松县| 安庆市| 寿宁县| 抚顺市| 巴林右旗| 永德县| 河源市| 阿坝| 东台市| 郸城县| 沛县| 乌审旗| 卓尼县| 仪陇县| 镇赉县| 孟村| 陈巴尔虎旗| 镇安县| 祁东县| 铁岭市| 革吉县| 洛川县| 措美县| 东山县| 工布江达县| 清新县| 禄劝| 临潭县| 古田县| 甘孜县| 新安县| 郧西县| 江达县|