JointJs 轨迹动画
JointJs是基于svg的,所以应该先了解svg的轨迹动画构成。
主要是根据animateMotion 和mpath ,其中animateMotion 和mpath 要分别绑定线和需要沿路径移动物体的id。代码如下:
<animateMotion joint-selector="p4" id="v-86" dur="3s" begin="0s" fill="freeze" xlink:href="#v-84" repeatCount="indefinite" rotate="auto">
<mpath xlink:href="#v-83"></mpath>
</animateMotion>
但是JointJs的连线和节点都是动态写入的,要想实现轨迹运动就只能依赖他的代码。查看了源码以后才找到这个方法:
Object.keys(links).forEach(function(key) {
links[key].findView(paper).sendToken(V('path', { stroke: scope.data.color.lineColor,strokeWidth: 1,fill: scope.data.color.lineColor,d: "M0,-3L15,0L0,3",transform:"translate(-7,0)",filter:"url(#f3)"}).node)
});
这一段{ stroke: scope.data.color.lineColor,strokeWidth: 1,fill: scope.data.color.lineColor,d: "M0,-3L15,0L0,3",transform:"translate(-7,0)",filter:"url(#f3)"},需要做轨迹运动的样式。

浙公网安备 33010602011771号