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

mpvue實現(xiàn)小程序簽到金幣掉落動畫(api實現(xiàn))

 更新時間:2019年10月17日 10:16:17   作者:MmM豆  
這篇文章主要介紹了mpvue實現(xiàn)小程序簽到金幣掉落動畫,這里使用小程序自帶的api來實現(xiàn),文中通過實例代碼給大家介紹的非常詳細(xì),需要的朋友可以參考下

這里使用小程序自帶的api來實現(xiàn),用小程序來寫動畫的惡心點(diǎn)在于,沒有幀,只能用setimeout 來作為幀來使用,

下面是實現(xiàn)代碼, 下面是簡單用div代替了圖片,需要什么圖片,可以自行替換相應(yīng)的div即可

需要變成原生小程序,則需要修改一下代碼的寫法

效果圖:

創(chuàng)建金幣動畫組件 clockAnimation.vue

<template>
 <div class="container" v-if='isShow'>
  <!-- 創(chuàng)建金幣對象 -->
  <!-- 大金幣 -->
  <div :class="coinShow?'coinShow bgCoin':'bgCoin'" :animation="bgCoinAnimation" ></div>
  <!-- 7個小金幣 -->
  <div :class="coinShow?'coinShow coin coin1':' coin coin1'" :animation="coinAnimation1">1</div>
  <div :class="coinShow?'coinShow coin coin2':' coin coin2'" :animation="coinAnimation2">2</div>
  <div :class="coinShow?'coinShow coin coin3':' coin coin3'" :animation="coinAnimation3">3</div>
  <div :class="coinShow?'coinShow coin coin4':' coin coin4'" :animation="coinAnimation4">4</div>
  <div :class="coinShow?'coinShow coin coin5':' coin coin5'" :animation="coinAnimation5">5</div>
  <div :class="coinShow?'coinShow coin coin6':' coin coin6'" :animation="coinAnimation6">6</div>
  <div :class="coinShow?'coinShow coin coin7':' coin coin7'" :animation="coinAnimation7">7</div>
 </div>
</template>
<script>
 export default{
  data() {
   return {
    coinShow:false,//金幣對象是否顯示,用于重置動畫時,隱藏對象
    isShow:false, //遮罩顯示
   //大金幣動畫
   bgCoinAnimation:{},
   //小金幣動畫
   coinAnimation1:{},
   coinAnimation2:{},
   coinAnimation3:{},
   coinAnimation4:{},
   coinAnimation5:{},
   coinAnimation6:{},
   coinAnimation7:{},
   }
  },
  methods: {
      //動畫
   animation(){
    this.coinShow =false
     this.isShow = true
    this.bgAnimation()
    this.smallAnimation()
  },
  //大金幣動畫
  bgAnimation(){
     var animation = wx.createAnimation({
    duration:1000,
   timingFunction: 'ease-in-out',
  })
    this.timer = setTimeout(()=>{
      animation.translate3d(0,30,0).step().translate3d(0,0,0).step().rotate(80).step({duration:400}).rotate(0).step({duration:500})
   this.bgCoinAnimation = animation.export()
    },100)
     setTimeout(()=>{
   animation.opacity(0).scale(4).step()
   this.bgCoinAnimation = animation.export()
  },3000)
   },
   //小金幣動畫
   smallAnimation(){
      var animation = wx.createAnimation({
    duration:1000,
   timingFunction: 'ease-in-out',
  })
  animation.translate3d(0,30,0).step().translate3d(0,0,0).step()
  setTimeout(()=>{
    this.coinAnimation1 = animation
  },300)
  setTimeout(()=>{
    this.coinAnimation2 = animation
  },500)
  setTimeout(()=>{
    this.coinAnimation3 = animation
  },600)
  setTimeout(()=>{
    this.coinAnimation4 = animation
  },700)
  setTimeout(()=>{
    this.coinAnimation5 = animation
  },800)
  setTimeout(()=>{
    this.coinAnimation6 = animation
  },900)
  setTimeout(()=>{
    this.coinAnimation7 = animation.export()
  },1000)
 //小金幣掉落動畫
  setTimeout(()=>{
    animation.translate3d(0,1000,0).step()
    this.coinAnimation1 = animation
    this.coinAnimation2 = animation
    this.coinAnimation3 = animation
    this.coinAnimation4 = animation
    this.coinAnimation5= animation
    this.coinAnimation6 = animation
    this.coinAnimation7 = animation
  },3000)
 //動畫結(jié)束,重置動畫初始位置
  setTimeout(()=>{
   this.coinShow =true
      var animation = wx.createAnimation({
       duration:300,
   timingFunction: 'ease-in-out',
  })
      var animation2 = wx.createAnimation({
       duration:300,
   timingFunction: 'ease-in-out',
  })
   animation.translate3d(0,-1000,0).step()
   animation2.translate3d(0,-1000,0).step().scale(1).step()
    this.bgCoinAnimation = animation2.export()
    this.coinAnimation1 = animation
    this.coinAnimation2 = animation
    this.coinAnimation3 = animation
    this.coinAnimation4 = animation
    this.coinAnimation5= animation
    this.coinAnimation6 = animation
    this.coinAnimation7 = animation
   setTimeout(()=>{
    this.isShow = false
   },500)
  },4000)
   }
   },
  mounted () {
  },
  onShow(){
  }
 }
</script>
<style lang="scss" scoped>
.container{
 position:absolute;
 top:0;
 left: 0;
 width: 100%;
 height: 100vh;
 // z-index: 999;
 background: rgba(5, 5, 5,0.5)
}
.bgCoin{
 background: rgb(233, 201, 19);
 border-radius: 50%;
 width: 100rpx;
 height: 100rpx;
 position: absolute;
 left: 350rpx;
 margin-left:-50rpx;
 top:600rpx;
  text-align: center;
  line-height: 100rpx;
  color: #ffffff;
  transform:rotate(180deg);
  transform:translate3d(0,-1000rpx,0);
}
.coinShow{
 opacity: 0;
}
.coin{
 background: rgb(233, 201, 19);
 border-radius: 50%;
 width: 50rpx;
 height: 50rpx;
  position: absolute;
  font-size: 24rpx;
  text-align: center;
  line-height: 40rpx;
  color: #ffffff;
  transform:translate3d(0,-1000rpx,0);
}
.coin1{
 top:40rpx;
 left:60rpx;
}
.coin2{
 top:90rpx;
 left:200rpx;
}
.coin3{
 top:860rpx;
 left:250rpx;
}
.coin4{
 top:150rpx;
 left:600rpx;
}
.coin5{
 top:270rpx;
 left:500rpx;
}
.coin6{
 top:490rpx;
 left:580rpx;
}
.coin7{
 top:350rpx;
 left:150rpx;
}
</style>

使用 引入組件

<template>
  <view>
   <view @click="clockInAnimation">立即簽到</view>
 <clockAnimation :isShow="clockIsShow" ref="clockAnimation"></clockAnimation>
 </view>
</template>
<script>
     //引入組件
   import clockAnimation from "../../components/clockAnimation.vue";  
 export default {
 components: {
  clockAnimation
 },
 data() {
   return {
      clockIsShow: false,
   }
 },
  methods: {
  clockInAnimation() {
   this.clockIsShow = true;
   this.$refs.clockAnimation.animation();
  },
  }
</script>

總結(jié)

以上所述是小編給大家介紹的mpvue實現(xiàn)小程序簽到金幣掉落動畫(api實現(xiàn)),希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復(fù)大家的。在此也非常感謝大家對腳本之家網(wǎng)站的支持!
如果你覺得本文對你有幫助,歡迎轉(zhuǎn)載,煩請注明出處,謝謝!

相關(guān)文章

  • openlayers實現(xiàn)地圖彈窗

    openlayers實現(xiàn)地圖彈窗

    這篇文章主要為大家詳細(xì)介紹了openlayers實現(xiàn)地圖彈窗,文中示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2020-09-09
  • element?ui?-?el-button?重新渲染后disabled屬性失效問題解決

    element?ui?-?el-button?重新渲染后disabled屬性失效問題解決

    這篇文章主要介紹了elementui el-button重新渲染后disabled屬性失效問題解決,解決方法也很簡單,給el-button元素添加key值就可以了,需要的朋友可以參考下
    2023-07-07
  • javascript判斷機(jī)器是否聯(lián)網(wǎng)的2種方法

    javascript判斷機(jī)器是否聯(lián)網(wǎng)的2種方法

    只有機(jī)器已經(jīng)聯(lián)網(wǎng)以后,web應(yīng)用才能啟動,下面使用javascript判斷機(jī)器是否聯(lián)網(wǎng),具體判斷代碼如下,有此需求的朋友可以參考下
    2013-08-08
  • elementui的select實現(xiàn)多選添加功能

    elementui的select實現(xiàn)多選添加功能

    這篇文章主要介紹了elementui的select實現(xiàn)多選添加功能,本文通過實例代碼給大家介紹的非常詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友可以參考下
    2023-03-03
  • JavaScript的null和undefined區(qū)別示例介紹

    JavaScript的null和undefined區(qū)別示例介紹

    在Javascript中對于這種生命后沒有給定初始值的變量,就給他一個undefined,如果要將一個標(biāo)識符聲明稱object類型,但是暫時不給他實例,那么就可以將它先初始化為null
    2014-09-09
  • 如何在TypeScript?中實現(xiàn)接口的類

    如何在TypeScript?中實現(xiàn)接口的類

    這篇文章主要介紹了TypeScript?中實現(xiàn)接口的類,本文給大家介紹的非常詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友可以參考下
    2023-03-03
  • JS實現(xiàn)選項卡實例詳解

    JS實現(xiàn)選項卡實例詳解

    這篇文章主要介紹了JS實現(xiàn)選項卡的方法,結(jié)合實例形式詳細(xì)講述了JavaScript實現(xiàn)選項卡的布局與功能實現(xiàn)的完整步驟及相關(guān)技巧,需要的朋友可以參考下
    2015-11-11
  • 基于js?+?html2canvas實現(xiàn)網(wǎng)頁放大鏡功能

    基于js?+?html2canvas實現(xiàn)網(wǎng)頁放大鏡功能

    最近接到任務(wù),需實現(xiàn)【網(wǎng)頁】放大鏡的效果,百度搜索?【js?放大鏡】關(guān)鍵字,千篇一律的都是一些仿淘寶/京東等電商網(wǎng)站中查看規(guī)格大圖的效果實現(xiàn),根本無法滿足我的需求,于是自己花了點(diǎn)時間調(diào)研實現(xiàn),在這里分享給大家,感興趣的朋友可以參考下
    2023-12-12
  • JavaScript中兩個感嘆號的作用說明

    JavaScript中兩個感嘆號的作用說明

    用兩個感嘆號的作用就在于,如果明確設(shè)置了o中flag的值(非null/undefined/0""/等值),自然test就會取跟o.flag一樣的值;如果沒有設(shè)置,test就會默認(rèn)為false,而不是null或undefined
    2011-12-12
  • JavaScript繼承模式粗探

    JavaScript繼承模式粗探

    之前提到了JS中比較簡單的設(shè)計模式,在各種設(shè)計模式中被最常使用的工具之一就是原型鏈的繼承。作為OOP的特質(zhì)之一——繼承,今天主要談?wù)凧S中比較簡單的繼承方法
    2016-01-01

最新評論

桑植县| 刚察县| 德阳市| 湘潭县| 正镶白旗| 抚州市| 韩城市| 兰坪| 南华县| 嘉黎县| 宝山区| 靖边县| 六枝特区| 北宁市| 五寨县| 荆门市| 盐亭县| 巴林右旗| 马边| 白城市| 平原县| 弥渡县| 八宿县| 苗栗市| 寿光市| 隆回县| 都匀市| 大化| 保靖县| 南丰县| 饶河县| 五河县| 奇台县| 永平县| 蒙山县| 邵阳县| 栖霞市| 宜都市| 南平市| 湖口县| 渭源县|