没有合适的资源?快使用搜索试试~ 我知道了~
首页jsplumb实例及API
jsplumb实例及API

jsplumb实例及APIjsplumb实例及APIjsplumb实例及APIjsplumb实例及API
资源详情
资源评论
资源推荐

view demo|contact me
Index
Summary
Changes since version 1.2.4
Imports
jsPlumb Basic Concepts
jsPlumb Basic Concepts - Simple Connections
jsPlumb Basic Concepts - Draggable Connections
jsPlumb Basic Concepts - Drag Options
jsPlumb Basic Concepts - Drop Options
jsPlumb Basic Concepts - Drag and Drop Scope
Multiple Instances of jsPlumb
Automatic repaint
Unloading jsPlumb
jsPlumb.connect Options
jsPlumb.detach Options
Defaults
Anchors
Dynamic Anchors
Connectors
Overlays
Endpoints
Endpoint Operations
Endpoint UUIDs
Gradients
Animation
Events
CSS Class Reference
Basic Examples
Draggable Connections Examples
Retrieving Connection Information
Advanced - jsPlumb internals
Pluggable Library Support
NOTE: This document refers to release 1.2.5 of jsPlumb.24 January
2011
Summary
jsPlumb allows you to connect elements on the screen with "plumbing", using
a Canvas element when supported, and Google'sExplorerCanvasscript to
support older browsers.

It can be used with jQuery, MooTools or YUI3 (or another library of your
choice if you feel like implementing a plugin for it). Required versions are as
follows:
jQuery
jQuery 1.3.x or 1.4.x. We have tested on 1.3.2, 1.4.2, 1.4.3 and 1.4.4.
jQuery UI 1.7.x or 1.8.x (if you wish to support drag and drop). We
have tested on 1.7.2 and 1.8.0.
MooTools
MooTools Core 1.2.4. It's possible other 1.2.x versions will work; we
have tested only with 1.2.4.
Drag.Move from MooTools More 1.2.4.4 (if you wish to support drag
and drop). Again, it's possible other versions will work, but we've tested
with just this one.
YUI3
YUI 3.3.x. We've only tested on 3.3.0; it is possible other 3.x.x versions
will work.
For Canvas support in IE you also need to include
Google'sExplorerCanvasscript.
jsPlumb 1.2.5 has been tested on the following browsers:
IE 7 on Windows Vista
IE 8 on Windows Vista (we force IE7 standards compatibility mode)
Firefox 3.5.8 on Windows Vista
Firefox 3.6.3 on Ubuntu 10.04
Chrome 6 on Ubuntu 10.04
Safari 4 on Mac Tiger
Safari 4 on Windows Vista
Opera 10.54 on Windows Vista
Changes since version 1.2.4
introduced support for YUI3
jsPlumb.connect now supports a 'dynamicAnchors' property
jsPlumb.makeAnchor and jsPlumb.makeDynamicAnchor are
deprecated

jsPlumb.autoConnect method removed. The same behaviour can be
achieved with the 'dynamicAnchors' parameter on a jsPlumb.connect
call.
These issues have been fixed:
issue 52 - a connection dragged away cannot be reconnected to its
original Endpoint
issue 53 - detach event fired 3 times when connection is dragged away
Imports
jQuery
Example using jQuery 1.3.x or 1.4.x, jQueryUI 1.7.x or 1.8.x, and
ExplorerCanvas:
<script type="text/javascript"
src="http://explorercanvas.googlecode.com/svn/trunk/excanvas.js"
></script>
<script type="text/javascript"
src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"
></script>
<script type="text/javascript"
src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.2/jquery-
ui.min.js"></script>
<script type="text/javascript" src="PATH_TO/jquery.jsPlumb-1.2.5-
all-min.js "></script>
MooTools
Example using MooTools 1.2.4, Drag.Move from MooTools More 1.2.4.4, and
ExplorerCanvas:
<script type="text/javascript"
src="http://explorercanvas.googlecode.com/svn/trunk/excanvas.js"
></script>
<script type="text/javascript"
src="http://ajax.googleapis.com/ajax/libs/mootools/1.2.4/mootools-
yui-compressed.js"></script>
<script type="text/javascript"
src="PATH_TO_MOO_TOOLS_MORE_1_2_4_4"></script>
<script type="text/javascript" src="PATH_TO/mootools.jsPlumb-
1.2.5-all-min.js "></script>
YUI3

Example using YUI 3.3.0 and ExplorerCanvas:
<script type="text/javascript"
src="http://explorercanvas.googlecode.com/svn/trunk/excanvas.js"
></script>
<script type="text/javascript"
src="http://yui.yahooapis.com/3.3.0/build/simpleyui/simpleyui-
min.js"></script>
<script type="text/javascript" src="PATH_TO/yui.jsPlumb-1.2.5-all-
min.js "></script>
jsPlumb Basic Concepts
There are five core concepts in jsPlumb:
Connector - a line connecting two elements in the page
Endpoint - the visual representation of one end of a Connection
Anchor - a location, relative to an element's origin, at which an
Endpoint can exist
Overlay - a UI component that is used to decorate a Connector, such
as a label, arrow, etc.
Connection - an instance of Anchors, Endpoints and a Connector with
zero or more Overlays working together to join two elements.
Connecting two elements - making a Connection - involves three steps:
1. Create an Anchor for each of the two elements you wish to connect.
2. Create an Endpoint for each of these Anchors, and assign them.
3. Join the two Endpoints with a Connector.
Depending on whether or not you wish to be able drag new Connections, step
2 can be omitted.
Simple Connections
This section discusses Connections in which you do not need to support drag
and drop.
The most simple connection you can make looks like this:
jsPlumb.connect({source:'element1', target:'element2'});
Note: if you're using jQuery, the 'connect' method is aliased with this
shorthand (this applies to all the examples using the 'connect' method, but I
won't mention it again):
$("#element1").plumb({target:'element2'});

In this example we have created a Connection from 'element1' to 'element2'.
What happened to the three steps I mentioned above? Well, jsPlumb provides
defaults foreverything. So in this example, behind the scenes jsPlumb used
default values for all of these things:
the Anchors that define where the connection's Endpoints appear on
each element
the type and appearance of each Endpoint in the Connection
the type and appearance of the Connection's Connector
Default values are discussed in detail in theDefaultssection below.
TheBasic Examplessection below contains many more examples of how to
create simple Connections.
Draggable Connections
To support draggable Connections, you are required to first create Endpoints,
as it is Endpoints that the user drags to create new Connections. Endpoints
are created by making anaddEndpointcall, passing in the target element's id
and an options object. There are quite a few things that can be set on the
options object; all of these parameters are optional.
endpoint - the type of Endpoint, eg. Dot, Rectangle, Image.
anchor - the Endpoint's Anchor, ie. where it will be located. this may be
a string - "TopCenter", for example, or an array of coordindates - [ 0.5,
0, 0, -1 ], or an array of individual anchor specifications, in which case
jsPlumb will make a 'dynamic' anchor for the Endpoint.
style - the Endpoint's appearance
isSource - a boolean indicating whether or not the Endpoint can be a
source for new Connections. Default is false.
isTarget - a boolean indicating whether or not the Endpoint can be a
target for new Connections. Default is false.
connector - the type of Connector to use when dragging a new
connection from this Endpoint. Optional.
connectorStyle - the Connector's appearance (see above).
dragOptions - options to pass to the supporting library's drag engine.
dropOptions - options to pass to the supporting library's drop engine.
connectorOverlays - a list of overlays that should be present on all
Connections attached to this Endpoint.
Here's a simple example of how to create an Endpoint:
var endpointOptions = { isSource:true, isTarget:true };
var endpoint = jsPlumb.addEndpoint('elementId', endpointOptions);
剩余49页未读,继续阅读
















安全验证
文档复制为VIP权益,开通VIP直接复制

评论18