小程序官方参考文档:https://developers.weixin.qq.com/miniprogram/dev/api/wx.createAnimation.html
写了一个简单的小demo,今天太晚了,就不继续写了,后续会继续写一个关于点击筛选按钮,从右往左弹出一个遮罩选择层的效果。
wxml

<view class="container">
<view class="animation-element-wrapper">
<view class="animation-element" animation="{{animation}}"></view>
</view>
<button class="animation-button" bindtap="translate">移动</button></view>
wxss
.animation-element-wrapper {
display: flex;
width: 100%;
padding-top: 150rpx;
padding-bottom: 150rpx;
justify-content: center;
overflow: hidden;
background-color: #ffffff;}.animation-element {
width: 80rpx;
height: 80rpx;
background-color: #1AAD19;}.animation-button {
float: left;
line-height: 2;
width: 300rpx;
margin: 15rpx 12rpx;}
js
Page({
onReady: function () {
this.animation = wx.createAnimation()
},
translate: function () {
this.animation.translate(-50, -1).step()
this.setData({animation: this.animation.export()})
},})
链接:https://www.jianshu.com/p/1cdf36070205