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
爲什麼動畫不平滑,我錯過了什麼?