Comparing version 0.0.62 to 0.0.63
@@ -11,6 +11,11 @@ 'use strict'; | ||
var _TextOutline = require('./text/TextOutline'); | ||
var _TextOutline2 = _interopRequireDefault(_TextOutline); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
exports.default = { | ||
TextWrap: _TextWrap2.default | ||
TextWrap: _TextWrap2.default, | ||
TextOutline: _TextOutline2.default | ||
}; |
@@ -27,2 +27,6 @@ 'use strict'; | ||
/** | ||
* TODO: this is horrible. figure this out. | ||
*/ | ||
var TextWrap = function (_React$Component) { | ||
@@ -43,4 +47,8 @@ _inherits(TextWrap, _React$Component); | ||
width = _props.width, | ||
y = _props.y, | ||
dy = _props.dy, | ||
_props$y = _props.y, | ||
y = _props$y === undefined ? 1 : _props$y, | ||
_props$x = _props.x, | ||
x = _props$x === undefined ? 1 : _props$x, | ||
_props$dy = _props.dy, | ||
dy = _props$dy === undefined ? 0 : _props$dy, | ||
lineHeight = _props.lineHeight; | ||
@@ -52,2 +60,3 @@ | ||
var word = void 0; | ||
var tspan = this.tspan; | ||
@@ -58,15 +67,20 @@ var words = text.split(/\s+/).reverse(); | ||
line.push(word); | ||
this.tspan.textContent(line.join(" ")); | ||
if (this.getComputedTextLength() > width) { | ||
var newText = line.join(" "); | ||
tspan.textContent = newText; | ||
if (tspan.getComputedTextLength() > width) { | ||
line.pop(); | ||
this.tspan.textContent(line.join(" ")); | ||
newText = line.join(" "); | ||
tspan.textContent = newText; | ||
line = [word]; | ||
var newLine = document.createElementNS(svgNS, 'tspan'); | ||
newLine.setAttribueNS(svgNS, 'x', 0); | ||
newLine.setAttributeNS(svgNS, 'x', x); | ||
newLine.setAttributeNS(svgNS, 'y', y); | ||
newLine.setAttributeNS(svgNS, 'dy', ++lineNumber + lineHeight + dy + 'em'); | ||
newLine.textContent(word); | ||
newLine.setAttributeNS(svgNS, 'dy', ++lineNumber * lineHeight + 'em'); | ||
newLine.textContent = ' ' + word; | ||
this.tspan.append(newLine); | ||
this.tspan.parentNode.append(newLine); | ||
tspan = newLine; | ||
} | ||
@@ -76,8 +90,2 @@ } | ||
}, { | ||
key: 'getComputedTextLength', | ||
value: function getComputedTextLength() { | ||
if (!this.tspan) return 0; | ||
return this.tspan.getComputedTextLength(); | ||
} | ||
}, { | ||
key: 'render', | ||
@@ -91,3 +99,5 @@ value: function render() { | ||
y = _props2.y, | ||
dy = _props2.dy; | ||
dy = _props2.dy, | ||
lineHeight = _props2.lineHeight, | ||
width = _props2.width; | ||
@@ -97,14 +107,10 @@ return _react2.default.createElement( | ||
null, | ||
_react2.default.createElement( | ||
'tspan', | ||
{ | ||
ref: function ref(c) { | ||
_this2.tspan = c; | ||
}, | ||
x: x, | ||
y: y, | ||
dy: dy | ||
_react2.default.createElement('tspan', { | ||
ref: function ref(c) { | ||
_this2.tspan = c; | ||
}, | ||
text | ||
) | ||
x: x, | ||
y: y, | ||
dy: dy | ||
}) | ||
); | ||
@@ -111,0 +117,0 @@ } |
{ | ||
"name": "@vx/text", | ||
"version": "0.0.62", | ||
"version": "0.0.63", | ||
"description": "vx text", | ||
@@ -5,0 +5,0 @@ "main": "build/index.js", |
No README
QualityPackage does not have a README. This may indicate a failed publish or a low quality package.
Found 1 instance in 1 package
9900
7
202
0
22