jointjs Element

jointjs Element

标准形状库中有很多现成 的已经定义的元素直接可以用.可以一自己去创建一些自定义类joint.dia.Element.
关于新建的元素的一些属性可以在定义元素之后再次进行覆盖修改.
关于标准库创建图形元素的使用方法:

var rectangle = new joint.shapes.standard.Rectangle();
rectangle.resize(100, 100);
//关于resize的一些用法
//element.resize(width, height [, opt])
//opt是一个参数用来定义大小改变的方向
//resize来调节大小,可以选择性的调节大小。举个例子,如果在一个长方形rect上添加了一个新的元素文本框
//并且期望当调整元素大小时,矩形rect被调整,而文本大小保持不变,保持在矩形正中心。
//通过把<g class"scalable"/>添加到rect的makeup中
//并且将文本的元素设置<text ref-x=".5" ref-y=".5" ref="rect" />
rectangle.position(50, 10);
rectangle.attr('root/title', 'joint.shapes.standard.Rectangle');
rectangle.attr('label/text', 'Rectangle');
rect2.attr({
    label: {
        text: 'World!'
    }
});
rect2.attr('label', {
    text: 'World!'
});//也可以用这种形式写
rectangle.attr('body/fill', 'lightblue');
//官网给出
//root:SVGGElement,结点容器????
//body:SVGRectElement,rect图形 的外形属性
//lable:SVGTextElement,body中的文本
//通过.attr来修改
rectangle.addTo(graph);

dia.element
一个图的元素模型
SVG的一些属性设置在arrt上,可以找到SVG属性的列表以及它们的描述.
每个dia.Element都定义了SVG标记,然后由dia.ElementView使用SVG的markup将元素呈现给paper

the joint.shapes.basic.Rect element (继承自joint.dia.Element)定义他的markup:
<g class="rotatable"><g class="scalable"><rect/></g><text/></g>
rotatable:可旋转     scalable:可拉伸
 change - generic event triggered for any change on the element - fn(element, opt)
 change:position - triggered when the element changes its position - fn(element, newPosition, opt)
 change:angle - triggered when the element gets rotated - fn(element, newAngle, opt)//旋转触发
 change:size - triggered when the element gets resized - fn(element, newSize, opt)//大小改变触发
 change:attrs - triggered when the element changes its attributes - fn(element, newAttrs, opt)//属性触发
 
// Listening for changes of the position to a single element
element1.on('change:position', function(element1, position) {
  alert('element1 moved to ' + position.x + ',' + position.y);
});//在哪里在那个cell上(element1),发生什么(change:position),发生后做什么(function),可以得到什么参数(position)
// All elements events are also propagated to the graph.
graph.on('change:position', function(element, position) {
  console.log('Element ' + element.id + 'moved to ' + position.x + ',' + position.y);
});
// Using the option parameter and a custom attribute
graph.on('change:custom', function(element, custom, opt) {
  if (opt.consoleOutput) {
    console.log('Custom attribute value changed to "' + custom + '"');
  }
});//????
element2.prop('custom', 'myValue', { consoleOutput: true });
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
element.js 是一个基于 Vue.js 的 UI 组件库,提供了丰富的可重用组件,用于快速搭建界面和交互。它由饿了么前端团队开发和维护,具有简洁易用、高效稳定的特点。 element.js 提供了各种常用的 UI 组件,如按钮、输入框、表格、日期选择器等等,可以满足大部分项目的需求。它支持自定义样式和主题,可以根据项目需求进行个性化的定制。同时,element.js 还提供了响应式设计,可以适应不同的设备和屏幕尺寸,使得用户体验更加友好。 element.js 不仅提供了基础的组件,还提供了一些复杂的组件,如弹窗、导航栏、轮播图等等,可以帮助开发者快速构建复杂的页面结构和功能。同时,它还提供了丰富的插件,如表单验证、异步加载等等,方便开发者进行项目开发和维护。 element.js 的文档和社区非常活跃,提供了详细的使用说明和示例代码,方便开发者学习和使用。开发者可以在官方网站上下载最新版本的 element.js,并在项目中引入使用。同时,element.js 也提供了完善的技术支持和问题解答,确保开发者可以顺利使用和运行。 总之,element.js 是一个强大而易用的 Vue.js UI 组件库,可以帮助开发者快速构建漂亮、高效的前端界面和交互。它具有丰富的组件和插件,支持自定义样式和主题,提供了响应式设计和优质的技术支持,可以大大提高前端开发的效率和质量。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值