Я новичок в JointJS и пытаюсь следовать этому руководству по созданию ссылок при перетаскивании элементов на друг над другом.
Когда я пытаюсь запустить его, я получаю эту ошибку в консоли Chrome:
Uncaught ReferenceError: g не определен
paper.on('cell:pointerup', function(cellView, evt, x, y) {
// Find the first element below that is not a link nor the dragged element itself.
var elementBelow = graph.get('cells').find(function(cell) {
if (cell instanceof joint.dia.Link) return false; // Not interested in links.
if (cell.id === cellView.model.id) return false; // The same element as the dropped one.
if (cell.getBBox().containsPoint(g.point(x, y))) {
return true;
}
return false;
});
// If the two elements are connected already, don't
// connect them again (this is application specific though).
if (elementBelow && !_.contains(graph.getNeighbors(elementBelow), cellView.model)) {
graph.addCell(new joint.dia.Link({
source: { id: cellView.model.id }, target: { id: elementBelow.id },
attrs: { '.marker-source': { d: 'M 10 0 L 0 5 L 10 10 z' } }
}));
// Move the element a bit to the side.
cellView.model.translate(200, 0);
}
});
Я вижу, что g никогда не создается в приведенном выше коде и не создается в учебнике, на что он ссылается?