这就是一个给元素画连接线的工具。

<!DOCTYPE html>
<html>
<head>
<title>jsPlumb</title>
<style>
.item{
width:100px;
height:50px;
border:3px solid green;
position: absolute;
}
.item1{
left:400px;
top:100px;
}
.item2{
left:300px;
top:250px;
}
.item3{
left:500px;
top:250px;
}
.item4{
left:200px;
top:400px;
}
.item5{
left:400px;
top:400px;
}
.item6{
left:600px;
top:400px;
}
</style>
</head>
<body>
<div class='demo' id='demo'>
<div class='item item1' id='item1'>1</div>
<div class='item item2' id='item2'>2</div>
<div class='item item3' id='item3'>3</div>
<div class='item item4' id='item4'>4</div>
<div class='item item5' id='item5'>5</div>
<div class='item item6' id='item6'>6</div>
</div>
<script src="jquery-2.1.1.js"></script>
<script src="jquery-ui-1.9.2.js"></script>
<script src="jquery.jsPlumb-1.4.1-all.js"></script>
<script>
jsPlumb.ready(function(){
var color = '#222';
var instance = jsPlumb.getInstance({
//连线
Connector:['Bezier', {curviness:50}],
//拖动时的演示
DragOptions:{cursor:'pointer', zIndex:2000},
//连接线的样式
PaintStyle:{strokeStyle:'steelblue', lineWidth:3},
//连接点的样式
EndpointStyle:{radius:6, fillStyle:'#222'},
//hover时线样式
HoverPaintStyle:{strokeStyle:'green'},
//hover时点的样式
EndpointHoverStyle:{fillStyle:'red'},
Container:'demo' //Either an element id, a DOM element, or a selector from the underlying library
});
instance.doWhileSuspended(function(){
var arrowCommon = {foldback: .7, fillStyle: color, width: 14},
overlays = [
['Arrow', {location:.8}, arrowCommon],
// ['Arrow', {location:.3, direction:-1}, arrowCommon],
];
var windows = jsPlumb.getSelector('.item'); for(var i = 0; i<windows.length;i++){
instance.addEndpoint(windows[i], {
uuid:windows[i].getAttribute('id')+'-bottom',
anchor:'Bottom',
maxConnections:-1
});
instance.addEndpoint(windows[i], {
uuid:windows[i].getAttribute('id')+'-top',
anchor:'Top',
maxConnections:-1
});
}
//connect 函数
instance.connect({uuids:['item3-bottom','item6-top'], overlays:overlays, detachable:true, reattach:true});
instance.connect({uuids:['item1-bottom','item2-top'], overlays:overlays});
instance.connect({uuids:['item1-bottom','item3-top'], overlays:overlays});
instance.connect({uuids:['item2-bottom','item4-top'], overlays:overlays});
instance.connect({uuids:['item2-bottom','item5-top'], overlays:overlays});
//jquery ui里的draggable功能
instance.draggable(windows);
});
jsPlumb.fire('jsPlumbdemoLoaded', instance);
})
</script>
</body>
</html>

这是一个简单的小例子。是官网中一个demo的简化版,在学习了网上的教程之后,给官网的例子加了自己的注释。

给元素加连接点,给连接点加连接线,给连接线加各种装饰。需要的样式,canvas和SVG中都有,需要的动作,就是拖动。

jsPlumb学习笔记的更多相关文章

  1. jsPlumb 学习笔记

    介绍 使用svg完成画图,四个概念: anchor: endpoint在的位置,可通过name访问 endpoint:connection的一端节点,通过addPoint makeSource, co ...

  2. 前端流程图jsplumb学习笔记

    1.这篇博客很好,另外两个是官网文档 http://www.cnblogs.com/leomYili/p/6346526.html https://jsplumbtoolkit.com/communi ...

  3. js学习笔记:webpack基础入门(一)

    之前听说过webpack,今天想正式的接触一下,先跟着webpack的官方用户指南走: 在这里有: 如何安装webpack 如何使用webpack 如何使用loader 如何使用webpack的开发者 ...

  4. PHP-自定义模板-学习笔记

    1.  开始 这几天,看了李炎恢老师的<PHP第二季度视频>中的“章节7:创建TPL自定义模板”,做一个学习笔记,通过绘制架构图.UML类图和思维导图,来对加深理解. 2.  整体架构图 ...

  5. PHP-会员登录与注册例子解析-学习笔记

    1.开始 最近开始学习李炎恢老师的<PHP第二季度视频>中的“章节5:使用OOP注册会员”,做一个学习笔记,通过绘制基本页面流程和UML类图,来对加深理解. 2.基本页面流程 3.通过UM ...

  6. 2014年暑假c#学习笔记目录

    2014年暑假c#学习笔记 一.C#编程基础 1. c#编程基础之枚举 2. c#编程基础之函数可变参数 3. c#编程基础之字符串基础 4. c#编程基础之字符串函数 5.c#编程基础之ref.ou ...

  7. JAVA GUI编程学习笔记目录

    2014年暑假JAVA GUI编程学习笔记目录 1.JAVA之GUI编程概述 2.JAVA之GUI编程布局 3.JAVA之GUI编程Frame窗口 4.JAVA之GUI编程事件监听机制 5.JAVA之 ...

  8. seaJs学习笔记2 – seaJs组建库的使用

    原文地址:seaJs学习笔记2 – seaJs组建库的使用 我觉得学习新东西并不是会使用它就够了的,会使用仅仅代表你看懂了,理解了,二不代表你深入了,彻悟了它的精髓. 所以不断的学习将是源源不断. 最 ...

  9. CSS学习笔记

    CSS学习笔记 2016年12月15日整理 CSS基础 Chapter1 在console输入escape("宋体") ENTER 就会出现unicode编码 显示"%u ...

随机推荐

  1. 读取数据库信息并生成表设计文档Word版本

    1.参考C#代码 using Help.DBAccessLayer.Business; using Help.DBAccessLayer.Model.SqlGenerator; using Newto ...

  2. ora-01652无法通过128(在temp表空间中)扩展temp段

    有两种错误:1.数据表空间不足 2.临时表空间不足 有两种原因:一是临时表空间空间太小,二是不能自动扩展. 分析过程:    既然是temp表空间有问题,那当然就要从temp表空间说起啦.首先要说明的 ...

  3. Web标准:九、CSS表单设计

    Web标准:九.CSS表单设计 知识点: 1.改变文本框和文本域样式 2.用图片美化按钮 3.改变下拉列表样式 4.用label标签提升用户体验   1)改变文本框和文本域样式 文本框标签:<i ...

  4. python之ftp作业【还未完成】

    作业要求 0.实现用户登陆 1.实现上传和下载 3.每个用户都有自己的家目录,且只可以访问自己的家目录 4.对用户进行磁盘配额,每个用户的空间不同,超过配额不允许下载和上传 5.允许用户在指定的家目录 ...

  5. php使用数组语法访问对象

    有一个对象,不过希望能用数组的语法来读写数据,可以使用 实现SPL的ArrayAccess接口来解决. 使用场景:加载配置文件类.larvel框架加载配置文件就这利用数组来操作对象. 数组式访问Obj ...

  6. Linux-——grep

    概念介绍 grep (global search regular expression(RE) and print out the line,全面搜索正则表达式并把行打印出来)是一种强大的文本搜索工具 ...

  7. nginx反向代理架构与安装配置(一)

    这里我们准备四台虚拟机,二台负载均衡(LB01,LB02),二台web服务器(WEB01,WEB02).   这里默认所有软件都安装在/data目录下.   四台虚拟机的初始安装是centos7的最小 ...

  8. 基于Jenkins的持续集成CI

    CI(continuous integration)持续集成 一次构建:可能包含编译,测试,审查和部署,以及其他一些事情,一次构建就是将源代码放在一起,并验证软件是否可以作为一个一致的单元运行的过程. ...

  9. 阈值分割与XLD轮廓拼接——第4讲

    一.阈值分割 阈值分割算子众多: threshold :这是最基本最简单的阈值算子. binary_threshold :它是自动阈值算子,自动选出暗(dark)的区域,或者自动选出亮(light)的 ...

  10. vue2.0 tab切换几种方式

    第一种 比较灵活简单的方式(切换改变部分的内容在组件中比较方便操作) <template> <div id="app"> <ul> <li ...