组件js代码中:
初始化动画
data: {
isPost: false,
postAnimationData: {},
},
ready() {
//评论组件动画
this.animation = wx.createAnimation({
//评论组件弹出动画
duration: 400, // 整个动画过程花费的时间,单位为毫秒
timingFunction: "ease", // 动画的类型
delay: 0, // 动画延迟参数
});
},
methods: {
// 发帖
handlePost() {
this.animation.bottom("0rpx").height("435rpx").step();
this.setData({
isPost: true,
postAnimationData: this.animation.export(),
});
},
closePost(e) {
// 设置动画内容为:使用绝对定位隐藏整个区域,高度变为0
this.animation.bottom("-100%").height("0rpx").step();
this.setData({
isPost: false,
postAnimationData: this.animation.export(),
});
},
}
html:
<view class="post-bottom" animation='{{postAnimationData}}'>
</view>