diff options
-rw-r--r-- | CHANGELOG.md | 1 | ||||
-rw-r--r-- | dist/svg.js | 13 | ||||
-rw-r--r-- | src/modules/optional/sugar.js | 12 |
3 files changed, 25 insertions, 1 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 8e09b70..5d74509 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,6 +26,7 @@ The document follows the conventions described in [“Keep a CHANGELOG”](http: - added `EventTarget` which is a baseclass to get event abilities (#641) - added `Dom` which is a baseclass to get dom abilities - added `round()` which lets you round attribues from a node +- added `ax(), ay(), amove()` to change texts x and y values directly (#787) ### Removed - removed `SVG.Array.split()` function diff --git a/dist/svg.js b/dist/svg.js index ba031c9..ff69c36 100644 --- a/dist/svg.js +++ b/dist/svg.js @@ -6,7 +6,7 @@ * @copyright Wout Fierens <wout@mick-wout.com> * @license MIT * -* BUILT: Thu Nov 08 2018 13:49:37 GMT+0100 (GMT+01:00) +* BUILT: Thu Nov 08 2018 13:57:26 GMT+0100 (GMT+01:00) */; var SVG = (function () { 'use strict'; @@ -5208,6 +5208,17 @@ var SVG = (function () { return a === 'leading' ? this.leading(v) : a === 'anchor' ? this.attr('text-anchor', v) : a === 'size' || a === 'family' || a === 'weight' || a === 'stretch' || a === 'variant' || a === 'style' ? this.attr('font-' + a, v) : this.attr(a, v); } + }); + registerMethods('Text', { + ax: function ax(x) { + return this.attr('x', x); + }, + ay: function ay(y) { + return this.attr('y', y); + }, + amove: function amove(x, y) { + return this.ax(x).ay(y); + } }); // Add events to elements var methods$1 = ['click', 'dblclick', 'mousedown', 'mouseup', 'mouseover', 'mouseout', 'mousemove', 'mouseenter', 'mouseleave', 'touchstart', 'touchmove', 'touchleave', 'touchend', 'touchcancel'].reduce(function (last, event) { diff --git a/src/modules/optional/sugar.js b/src/modules/optional/sugar.js index 9cdc662..69f723e 100644 --- a/src/modules/optional/sugar.js +++ b/src/modules/optional/sugar.js @@ -159,6 +159,18 @@ registerMethods(['Element', 'Runner'], { } }) +registerMethods('Text', { + ax (x) { + return this.attr('x', x) + }, + ay (y) { + return this.attr('y', y) + }, + amove (x, y) { + return this.ax(x).ay(y) + } +}) + // Add events to elements const methods = [ 'click', 'dblclick', |