我试图在路径上移动一个圆圈,从开始位置到最终位置
marker.transition().duration(1000).attrTween("transform", translateAlong_new(path.node(), startPoint, endPoint));
function translateAlong_new(path, startPoint, endPoint) {
var l = endPoint.longitud - 24;
console.log("l",l,"icinio",startPoint,"fin",endPoint);
return function() {
return function(t) {
console.log(t);
if (startPoint[0]>endPoint[0])
var p = path.getPointAtLength((1-t) * l);//code
else
var p = path.getPointAtLength(t * l);
var centerX = p.x, centerY = p.y - 100;
return "translate(" + centerX + "," + centerY + ")";
}
}
}
但我无法设置明星位置。 有什么想法吗?