0
我试图调用.attrTween()
来平滑地动画对象的y
属性。d3.attrTween()不能流畅地动画
下面是我使用的代码:https://jsbin.com/ceronufuha/edit?html,js,output
(当然这是一个过于简单化的例子)
:如果你想看看let svg = d3.select('svg')
svg.append('text')
.attr({ x: 100, y: 100 })
.text('I should be animated smoothly')
// animate consecutively through all positions
let positions = [10, 20, 15, 35, 70, 50, 30, 10, 30, 45]
svg.transition()
.duration(10000)
.ease('linear')
.selectAll('text')
.attrTween('y', function() {
return function(t) {
return positions[Math.floor(t * 10)]
}
})
这里的jsfiddle
为什么动画不平滑,我错过了什么?