Skip to content

Commit

Permalink
implement basic padding
Browse files Browse the repository at this point in the history
  • Loading branch information
nbond211 authored and davelandry committed Feb 27, 2018
1 parent 7f97137 commit f31ead5
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/TextBox.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export default class TextBox extends BaseClass {
this._id = (d, i) => d.id || `${i}`;
this._on = {};
this._overflow = constant(false);
this._padding = constant(0);
this._pointerEvents = constant("auto");
this._rotate = constant(0);
this._split = textSplit;
Expand Down Expand Up @@ -91,8 +92,8 @@ export default class TextBox extends BaseClass {
"line-height": lH
};

const h = this._height(d, i),
w = this._width(d, i);
const h = this._height(d, i) - (this._padding() * 2),
w = this._width(d, i) - (this._padding() * 2);

const wrapper = wrap()
.fontFamily(style["font-family"])
Expand Down Expand Up @@ -191,7 +192,7 @@ export default class TextBox extends BaseClass {
id: this._id(d, i),
tA: this._textAnchor(d, i),
widths: wrapResults.widths,
fS, lH, w, h, x: this._x(d, i), y: this._y(d, i) + yP
fS, lH, w, h, x: this._x(d, i) + this._padding(), y: this._y(d, i) + yP + this._padding()
});

}
Expand Down Expand Up @@ -448,6 +449,15 @@ function(d, i) {
return arguments.length ? (this._overflow = typeof _ === "function" ? _ : constant(_), this) : this._overflow;
}

/**
@memberof TextBox
@desc Sets the padding to the specified accessor function or static number, which is 0 by default.
@param {Function|Number} [*value*]
*/
padding(_) {
return arguments.length ? (this._padding = typeof _ === "function" ? _ : constant(_), this) : this._padding;
}

/**
@memberof TextBox
@desc Sets the pointer-events to the specified accessor function or static string.
Expand Down

0 comments on commit f31ead5

Please sign in to comment.