微信小程序动画效果
最近一直在做小程序开发,在官方文档中无意间看到过渡动画效果,我就有点小激动,用每一个开发框架的时候我都最先研究动画和过渡
闲来无事写了一个小demo
<view class="wrapper">
<view class="headerImage" catchtap="imageAnimation" animation="{{animationData}}">
<open-data type="userAvatarUrl" ></open-data>
</view>
<view class="headertext">
<open-data type="userNickName" class="headertext"></open-data>
</view>
</view>
.wrapper {
background: gold;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
height: 500rpx;
}
.headerImage {
width: 200rpx;
height: 200rpx;
margin-bottom: 40rpx;
}
.headertext {
font-size: 40rpx;
}
const app = getApp()
const computedBehavior = require('miniprogram-computed')
Component({
behaviors: [computedBehavior],)
data: {
animationData: "",
},
methods: {
imageAnimation() {
var animation = wx.createAnimation({
duration: 4000,
timingFunction: "ease",
delay: 0,
transformOrigin: "50% 50%",
})
this.setData({
animationData: animation.export(),
})
},
},
computed: {
},
})