种一颗树,最好的时机是十年期,而后是现在。
The best time to plant a tree was twenty years ago. The second-best time is now.
在微信小程序中,提供了这样一个API——wx.createAnimation(Object object)。该API创建一个动画实例 animation。调用实例的方法来描述动画。
本文主要介绍animation实例的倾斜相关的方法及其使用。
假设我们创建了这样一个实例:
this.animationData = wx.createAnimation({
duration: 1000
})
1. Animation…skew(number ax, number ay) 对 X、Y 轴坐标进行倾斜
参数:
number ax
对 X 轴坐标倾斜的角度,范围 [-180, 180]
number ay
对 Y 轴坐标倾斜的角度,范围 [-180, 180]
核心代码:
this.animationData.skew(45, 10).step()
效果如下
2. Animation.skewX(number angle) 对 X 轴坐标进行倾斜,倾斜的角度,范围 [-180, 180]
核心代码:
this.animationData.skewX(45).step()
效果如下
3. Animation.skewY(number angle) 对 Y 轴坐标进行倾斜
核心代码:
this.animationData.skewY(135).step()
效果如下
注: 以上效果均设置过渡时间为1000ms,即1s