微信小程序 连续旋转动画(this.animation.rotate)详解
2019/6/27 21:02:40
本文主要是介绍微信小程序 连续旋转动画(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就行!
感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!
这篇关于微信小程序 连续旋转动画(this.animation.rotate)详解的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-10-04package.json 文件位置在哪?-icode9专业技术文章分享
- 2024-10-01Craco.js学习:从入门到实践指南
- 2024-10-01Create-React-App学习:入门与实践指南
- 2024-10-01CSS-in-JS学习:从入门到实践指南
- 2024-09-30JSX语法学习:从入门到初步掌握
- 2024-09-30Mock.js学习:入门教程与实战演练
- 2024-09-30React Hooks学习:从入门到实践
- 2024-09-30受控组件学习:React中的基础入门教程
- 2024-09-29JS定时器教程:初学者必看指南
- 2024-09-29JS对象教程:初学者的全面指南