Animation.translate

解释: 平移变换

方法参数

Number tx,Number ty

参数说明

一个参数时,表示在X轴偏移 tx ,单位 px ;两个参数时,表示在 X 轴偏移 tx ,在 Y 轴偏移 ty ,单位 px 。

示例

在开发者工具中预览效果

扫码体验

请使用百度APP扫码

图片示例

代码示例

  1. <view class="wrap"> <view class="animation-element-wrapper"> <view class="animation-element" animation="{{animation}}"></view> </view> <view class="card-area"> <view class="top-description border-bottom">展示动画</view> <button type="primary" bindtap="translate">translate</button> </view></view>
  1. Page({ data:{ }, onReady() { this.animation = swan.createAnimation({ transformOrigin: "50% 50%", duration: 1000, timingFunction: "ease", delay: 0}) }, translate() { this.animation.translate(Math.random() * 100 - 50, Math.random() * 100 - 50).step() this.setData({animation: this.animation.export()}) }});