linkView.sendToken(token [, opt, callback])
Send a token along the link. token
is an SVG element (or Vectorizer element) that will be animated along the link path for opt.duration
milliseconds (default is 1000ms). The callback
function will be called once the token reaches the end of the link path.
opt.direction
specifies whether the animation should be played forwards ('normal'
- from the link source to target, the default) or backwards ('reverse'
).
Use opt.connection
to specify the SVGPathElement for the token to follow. It expects a string selector, e.g. '.connection'
.
// Send an SVG circle token along the link.
var vCircle = V('circle', { r: 7, fill: 'green' });
link.findView(paper).sendToken(vCircle, { duration: 500, direction: 'reverse' }, function() {
console.log('animation end');
});
Note that in the code above, we use the Vectorizer mini-library to create the SVG circle
element.
See the Petri Net simulator demo for a full working example.