我想知道动画路径过渡是否可以返回最后一个绘制的位置?。
ex:
path
.attr("stroke-dasharray", t1 + " " + t1)
.attr("stroke-dashoffset", t1)
.transition(d3.transition()
.duration(lap)
.ease(d3.easeLinear)
.attrTween( "e", function(d) {
return function( t ) {}})
.attr("stroke-dashoffset",0)
谢谢的
可以像这样定义补间及其工厂:
function tween (t) {
var totalLength = this.getTotalLength();
//a SVGPoint object with x/y properties
var position = this.getPointAtLength(total * t);
//...do something
}
function tweenFactory (d) {
return tween.bind(this);
}
如果在执行工厂时已在DOM中存在路径并且路径长度不变,则可以显然将totalLength
的计算移至工厂功能。