小程序animation向左移动动画

微信   2024-12-26 08:55   93   0  

小程序官方参考文档:https://developers.weixin.qq.com/miniprogram/dev/api/wx.createAnimation.html

写了一个简单的小demo,今天太晚了,就不继续写了,后续会继续写一个关于点击筛选按钮,从右往左弹出一个遮罩选择层的效果。
wxml

3387_qdd9_8518.png

<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


博客评论
还没有人评论,赶紧抢个沙发~
发表评论
说明:请文明发言,共建和谐网络,您的个人信息不会被公开显示。