删除节点后如何控制连接?

时间:2012-07-19 09:32:17

标签: javascript raphael graphiti-js

以下是撤消/重做的示例:Undo_Redo_Delete

我做了以下步骤:

  1. 拖放开始和结束节点。
  2. 通过端口连接。
  3. 删除结束节点。
  4. 现在再次拖动结束节点。
  5. 这次我再次尝试连接开始和结束节点,但它显示
  6. TypeError:this.parent.getCanvas()为null

    在port.js的this.parent.getCanvas()。connectionLine.setGlow(false)中。

    如果有人知道如何克服这个问题,那么请帮帮我。谢谢你提前:)

1 个答案:

答案 0 :(得分:1)

已修复版本0.9.38

如果需要快速修复,可以使用以下代码替换onDragEnd方法。

/**
 * @inheritdoc
 **/
onDragEnd:function()
{
  this.parent.getCanvas().setSnapToGrid(this.originalSnapToGrid );
  this.parent.getCanvas().setSnapToGeometry( this.originalSnapToGeometry );

  // Don't call the parent implementation. This will create an CommandMove object
  // and store them o the CommandStack for the undo operation. This makes no sense for a
  // port.
  // graphiti.shape.basic.Rectangle.prototype.onDragEnd.call(this); DON'T call the super implementation!!!

  this.setAlpha(1.0);

  // 1.) Restore the old Position of the node
  //
  this.setPosition(this.ox,this.oy);

  // 2.) Remove the bounding line from the canvas
  //
  this.parent.getCanvas().hideConnectionLine();
  this.isInDragDrop =false;

  // Reset the drag&drop flyover information 
  //
  this.currentTarget = null; // <<== this is the missing line to fix the bug
},