加入animation之后,位置发生了偏移
发布于 5 年前 作者 yixiuying 5639 次浏览 来自 问答

在点击蛋时,出现锤子,在锤子上加上动画之后,锤子不管上面的还是下面的都只在上面,横向没有问题,纵向一直不变

showKnock:function(e){

//锤子出现

var that=this;

//定义锤子动画

var animation2=wx.createAnimation({

duration:100,

timingFunction:“ease”,

delay:0,

transformOrigin: ‘right bottom 0’

})

//锤子旋转

animation2.rotate(-45).step();

//将点击时鼠标的横纵坐标赋值给锤子 并执行动画

that.setData({

flags:true,

left: e.detail.x,

top: e.detail.y,

slide_up2:animation2.export()

})

//鼠标每次点击都有效果 需要加定时器使得锤子复位

setTimeout(function () {

animation2.rotate(0).step({ duration: 0, transformOrigin: ‘50%,50%’, timingFunction: ‘linear’})

that.setData({

slide_up2: animation2.export()

})

},200)

},

回到顶部