diff options
Diffstat (limited to 'src/elements/Path.js')
-rw-r--r-- | src/elements/Path.js | 39 |
1 files changed, 20 insertions, 19 deletions
diff --git a/src/elements/Path.js b/src/elements/Path.js index 8f37319..018a8c6 100644 --- a/src/elements/Path.js +++ b/src/elements/Path.js @@ -16,31 +16,26 @@ export default class Path extends Shape { return this._array || (this._array = new PathArray(this.attr('d'))) } - // Plot new path - plot (d) { - return (d == null) ? this.array() - : this.clear().attr('d', typeof d === 'string' ? d : (this._array = new PathArray(d))) - } - // Clear array cache clear () { delete this._array return this } + // Set height of element + height (height) { + return height == null ? this.bbox().height : this.size(this.bbox().width, height) + } + // Move by left top corner move (x, y) { return this.attr('d', this.array().move(x, y)) } - // Move by left top corner over x-axis - x (x) { - return x == null ? this.bbox().x : this.move(x, this.bbox().y) - } - - // Move by left top corner over y-axis - y (y) { - return y == null ? this.bbox().y : this.move(this.bbox().x, y) + // Plot new path + plot (d) { + return (d == null) ? this.array() + : this.clear().attr('d', typeof d === 'string' ? d : (this._array = new PathArray(d))) } // Set element size to given width and height @@ -49,19 +44,25 @@ export default class Path extends Shape { return this.attr('d', this.array().size(p.width, p.height)) } + targets () { + return baseFind('svg textpath [href*="' + this.id() + '"]') + } + // Set width of element width (width) { return width == null ? this.bbox().width : this.size(width, this.bbox().height) } - // Set height of element - height (height) { - return height == null ? this.bbox().height : this.size(this.bbox().width, height) + // Move by left top corner over x-axis + x (x) { + return x == null ? this.bbox().x : this.move(x, this.bbox().y) } - targets () { - return baseFind('svg textpath [href*="' + this.id() + '"]') + // Move by left top corner over y-axis + y (y) { + return y == null ? this.bbox().y : this.move(this.bbox().x, y) } + } // Define morphable array |