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

微信小程序 连续旋转动画

创新互联主要从事成都网站设计、成都网站建设、网页设计、企业做网站、公司建网站等业务。立足成都服务太平,10年网站建设经验,价格优惠、服务专业,欢迎来电咨询建站服务:028-86922220

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

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

本文名称:微信小程序连续旋转动画(this.animation.rotate)详解
网址分享:https://www.cdcxhl.com/article22/gpeecc.html

成都网站建设公司_创新互联,为您提供网站导航定制网站企业建站用户体验搜索引擎优化小程序开发

广告

声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联

商城网站建设