【问题标题】:d3 transition not following pathd3 过渡不遵循路径
【发布时间】:2017-09-27 10:19:14
【问题描述】:

我喜欢让飞机跟随路径。但是无论我尝试过什么,过渡路径和屏幕上实际绘制的路径之间都会发生变化。请看jsfiddle

d3.selectAll('.aircraft').transition()
.duration(7500)
.attrTween('transform', translateAlong(d3.select('#samplePath').node()))

function translateAlong(path) {
    let l = path.getTotalLength()
        // debugger
        return function (i) {
        return function (t) {
            let p = path.getPointAtLength(t * l)
                console.log(p.x, p.y)
                return 'matrix(-0.359863 -0.230143 0.230143 -0.359863' + p.x + ' ' + p.y + ')'
        }
    }
}

【问题讨论】:

    标签: javascript d3.js transition


    【解决方案1】:

    您在矩阵定义中的第二个-0.359863 之后缺少一个空格:

    return 'matrix(-0.359863 -0.230143 0.230143 -0.359863 ' +  p.x + ' ' + p.y + ')'
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-07-14
      • 2015-04-21
      • 2018-10-20
      • 1970-01-01
      • 2019-02-22
      • 1970-01-01
      • 2012-07-10
      • 2016-03-18
      相关资源
      最近更新 更多