jsPlumb(2)-配置

感觉jsPlumb最容易最直观是重写jsPlumb的默认配置。若是你没这么作,你不得不每次调用都得重写这些值。connectaddEndpoint的每一个参数都和jsPlumb的默认值有关。javascript

默认设置存储在jsPlumb.Defaults,是个javascript对象。有效健,初始值以下:java

Anchor : "BottomCenter",
Anchors : [ null, null ],
ConnectionsDetachable   : true,
ConnectionOverlays  : [],
Connector : "Bezier",
Container : null,
DoNotThrowErrors  : false,
DragOptions : { },
DropOptions : { },
Endpoint : "Dot",
Endpoints : [ null, null ],
EndpointOverlays : [ ],
EndpointStyle : { fillStyle : "#456" },
EndpointStyles : [ null, null ],
EndpointHoverStyle : null,
EndpointHoverStyles : [ null, null ],
HoverPaintStyle : null,
LabelStyle : { color : "black" },
LogEnabled : false,
Overlays : [ ],
MaxConnections : 1,
PaintStyle : { lineWidth : 8, strokeStyle : "#456" },
ReattachConnections : false,
RenderMode : "svg",
Scope : "jsPlumb_DefaultScope"

注意:EndpointHoverStyle fillStyle是null
。也就是说jsPlumb使用来自Connector的hover style的strokeStyle来填充Endpoint。数组

EndpointStyleEndpointStyles你均可以定制,你能够让每一个链接的Endpoint都不同。EndpointEndpoints也同样。jsPlumb会先检查用户的EndpointEndpointStyle数组,而后再检查默认的。ssh

你能够经过importDefaults方法覆盖默认值:svg

jsPlumb.importDefaults({
  PaintStyle : {
    lineWidth:13,
    strokeStyle: 'rgba(200,0,0,0.5)'
  },
  DragOptions : { cursor: "crosshair" },
  Endpoints : [ [ "Dot", { radius:7 } ], [ "Dot", { radius:11 } ] ],
  EndpointStyles : [{ fillStyle:"#225588" }, { fillStyle:"#558822" }]
});

加载并执行这段代码后,就会获得效果。code

每条默认设置的解释

  • Anchor 对于那些没有声明Anchor的Endpoint,对Connection的source和target也适用。对象

  • Anchors 全部Connection的source和target的Anchorsip

  • Connector 给默认Connector使用get

  • ConnectionsDetachable Connections是否可经过鼠标分离io

  • Container

  • DoNotThrowErrors 当Anchor, Endpoint or Connector被请求却不存在时是否报错

  • ConnectionOverlays 默认Connection的遮罩

  • DragOptions 可经过jsPlumb.draggable配置

  • DropOptions 配置Endpoint是否能够drop链接

  • Endpoint Endpoint的定义

  • Endpoints jsPlumb.connect的source 和 target

  • EndpointOverlays 默认全部的Overlays

  • EndpointStyle

  • EndpointStyles

  • EndpointHoverStyle

  • EndpointHoverStyles

  • HoverPaintStyle

  • LabelStyle

  • LogEnabled

  • Overlays

  • MaxConnections

  • PaintStyle

  • ReattachConnections

  • RenderMode

  • Scope

jsPlumb.getInstance

经过 jsPlumb.getInstance

jsPlumb.getInstance({
  PaintStyle : {
    lineWidth:13,
    strokeStyle: 'rgba(200,0,0,100)'
  },
  DragOptions : { cursor: "crosshair" },
  Endpoints : [ [ "Dot", { radius:7 } ], [ "Dot", { radius:11 } ] ],
  EndpointStyles : [
    { fillStyle:"#225588" }, 
    { fillStyle:"#558822" }
  ]
});
相关文章
相关标签/搜索