linkView.sendToken(token, [options], [callback])
Send a token along the link. token
is an SVG element (or Vectorizer element) that will be animated along the link path for options.duration
milliseconds (default is 1000ms). callback
will be called once the token reaches the end of the link path. options.direction
specifies whether the animation should play fowards ('normal'
- from the link source to target, which is the default) or backwards ('reverse'
).
// 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.
Please see the Petri Net simulator demo for a full working example.