Skip to content

Commit

Permalink
added padding attribute to labelBoxAttrs; usage shown in utest
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidDurman committed Jan 18, 2011
1 parent 81e5afc commit 50c6a63
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/joint.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ if (!Array.indexOf){
* @param {boolean} [opts.beSmooth] Connection enable/disable smoothing
* @param {string} [opts.label] Connection label
* @param {object} [opts.labelAttrs] Label options (see Raphael possible parameters)
* @param {object} [opts.labelBoxAttrs] SVG Attributes of the label bounding rectangle.
* @param {object} [opts.labelBoxAttrs] SVG Attributes of the label bounding rectangle + padding attribute.
* @param {object} [opts.startArrow] Start arrow options
* @param {string} [opts.startArrow.type] "none"|"basic"
* @param {number} [opts.startArrow.size] Start arrow size
Expand Down Expand Up @@ -1372,7 +1372,8 @@ var JointDOMBuilder = {
var pos = this.labelLocation,
labelText = this.paper.text(pos.x, pos.y, this.opt.label).attr(this.opt.labelAttrs),
bb = labelText.getBBox(),
labelBox = this.paper.rect(bb.x, bb.y, bb.width, bb.height).attr(this.opt.labelBoxAttrs);
padding = this.opt.labelBoxAttrs.padding || 0,
labelBox = this.paper.rect(bb.x - padding, bb.y - padding, bb.width + 2*padding, bb.height + 2*padding).attr(this.opt.labelBoxAttrs);
labelText.insertAfter(labelBox);
return { text: labelText, box: labelBox };
},
Expand Down
4 changes: 3 additions & 1 deletion utests/label.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,9 @@ paper.circle(50, 550, 20).joint(paper.circle(720, 750, 30), {
'font-size': 25
},
labelBoxAttrs: {
fill: '90-#fff-#000'
fill: '90-#fff-#000',
padding: 10,
r: 15
}
}).setVertices(['250 550', '70 620', '70 700', '250 600', '250 750']).toggleSmoothing();

0 comments on commit 50c6a63

Please sign in to comment.