微信小程序连续旋转动画效果,如何设置微信小程序的连续动画旋转效果呢?

  微信小程序连续旋转动画效果,如何设置微信小程序的连续动画旋转效果呢?

  最近,一些小伙伴问我这样的一个问题。下面小编就来为大家讲解一下微信小程序连续旋转动画效果如何做?

  微信小程序 连续旋转动画

  一、.js中封装旋转动画方法

  添加animation属性

  data:{

  animation:''"

  }

  改变animation的值(官网提供角度范围是-180~180,但是我发现角度越大会一直旋转)

  onShow: function() {

  console.log('index---------onShow()')

  this.animation = wx.createAnimation({

  duration: 1400,

  timingFunction: 'linear', // "linear","ease","ease-in","ease-in-out","ease-out","step-start","step-end"

  delay: 0,

  transformOrigin: '50% 50% 0',

  success: function(res) {

  console.log("res")

  }

  })

  },

  rotateAni: function (n) {

  console.log("rotate=="+n)

  this.animation.rotate(180*(n)).step()

  this.setData({

  animation: this.animation.export()

  })

  },

  二、在.wxml中需要的控件上添加animation属性

  

image>


  view>

  三、连续动画需要添加定时器

  this.interval = setInterval所传参数每次++i就行!

  以上就是小编为大家整理的关于微信小程序连续旋转动画效果的内容。




卖贝商城更多商品介绍:网络红人Rachel小鱼儿微博大号广告代发价格     上海新闻综合电视广告投放    陕西电视台广告代理公司