微信小程序连续旋转动画this.animation.rotate

一、.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属性

  <view class="show-iconView">
      <image src="{{src}}" class="show-iconImage" animation="{{animation}}" mode="scaleToFill"></image>
  </view>

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

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

 

转载于:https://www.cnblogs.com/xianfeng-zhang/p/6671930.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值