Animation.translate3d

2020-08-21 16:01 更新

解释: 对 X、Y、Z 坐标进行平移变换

方法参数

Number tx, 在 X 轴偏移 tx

Number ty,在 Y 轴偏移 ty

Number tz ,在 Z 轴偏移 tz

单位 px。

示例


图片示例



代码示例 

在开发者工具中打开

<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="translate3d">translate3d</button>
    </view>
</view>
Page({
    onLoad() {
        this.animation = swan.createAnimation({
            transformOrigin: '50% 50%',
            duration: 1000,
            timingFunction: 'ease',
            delay: 0
        });
    },
    translate3d() {
        this.animation.translate3d(Math.random() * 100 - 50, Math.random() * 100 - 50, Math.random() * 100 - 50).step();
        this.setData({animation: this.animation.export()});
    }
});


以上内容是否对您有帮助:
在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号