微信小程序 连续旋转动画(this.animation.rotate)详解

2019-11-22,,

微信小程序 连续旋转动画

一、.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就行!

感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!

您可能感兴趣的文章:

  • 微信小程序实现元素渐入渐出动画效果封装方法
  • 微信小程序 小程序制作及动画(animation样式)详解
  • 微信小程序的动画效果详解
  • 微信小程序实现animation动画
  • 微信小程序实现登录页云层漂浮的动画效果
  • 微信小程序scroll-view组件实现滚动动画
  • 微信小程序loading组件显示载入动画用法示例【附源码下载】
  • 微信小程序开发animation心跳动画效果
  • 微信小程序开发之录音机 音频播放 动画实例 (真机可用)
  • 微信小程序实现渐入渐出动画效果

《微信小程序 连续旋转动画(this.animation.rotate)详解.doc》

下载本文的Word格式文档,以方便收藏与打印。