bindtransitionend调用次数为不对

发布于 7 年前作者 lei4014442 次浏览最后编辑 7 年前来自 ask
  • 当前 Bug 的表现(可附上截图)

用createAnimation创建动画,bindtransitionend去接收动画完成的回调。step动画是2个,bindtransitionend却被调用了三次。

  • 预期表现

  • 复现路径

  • 提供一个最简复现 Demo

doAnimation: function() {

this.opacityCount = 0;

var anim = wx.createAnimation({

});

anim.translate(0, 0).scale(1, 1).opacity(0).step({duration:1000, timingFunction:“linear”});

anim.translate(0, 0).scale(1, 1).opacity(1).step({ duration: 1000, timingFunction: “linear” });

this.setData({myanimation: anim.export()});

},

onAnimationEnd: function() {

//只加入了两个step动画,为何这个函数会被调用3次!!!

this.opacityCount++;

console.log(“opacityCount:” + this.opacityCount);

},

3 回复
qiang33
qiang331 楼6 年前

1、将demo中的bindtransitionend 换成bindanimationend后不触发事件了

2、我自己的项目中,不用官方提供的var anim = wx.createAnimation({})去设置动画,单纯的写在css中,然后监听bindanimationend就只触发一次<view class=‘options  {{ selected ? “animation” : “”}}’ bindanimationend=‘onAnimationEnd’></view>

tanjuan
tanjuan2 楼6 年前

好奇怪。。translate算了一次,opacity算了一次。。。

gang34
gang343 楼5 年前

就没有官方人员来看看这个问题吗?