Skip to content

Commit 7269c33

Browse files
committed
Legend: Switch to using Lib.getTranslate
1 parent 0cf82fe commit 7269c33

File tree

2 files changed

+6
-12
lines changed

2 files changed

+6
-12
lines changed

src/components/legend/draw.js

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -332,16 +332,10 @@ module.exports = function draw(gd) {
332332
dragElement.init({
333333
element: legend.node(),
334334
prepFn: function() {
335-
// regex pattern for 'translate(123.45px, 543.21px)'
336-
var re = /(.*\()(\d*\.?\d*)([^\d]*)(\d*\.?\d*)([^\d]*)/,
337-
transform = legend.attr('transform')
338-
.replace(re, function(match, p1, p2, p3, p4) {
339-
return [p2, p4].join(' ');
340-
})
341-
.split(' ');
342-
343-
x0 = +transform[0] || 0;
344-
y0 = +transform[1] || 0;
335+
var transform = Lib.getTranslate(legend);
336+
337+
x0 = transform.x;
338+
y0 = transform.y;
345339
},
346340
moveFn: function(dx, dy) {
347341
var newX = x0 + dx,

test/jasmine/tests/lib_test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -770,7 +770,7 @@ describe('Test lib.js:', function() {
770770
});
771771
});
772772

773-
fdescribe('getTranslate', function() {
773+
describe('getTranslate', function() {
774774

775775
it('should work with regular DOM elements', function() {
776776
var el = document.createElement('div');
@@ -814,7 +814,7 @@ describe('Test lib.js:', function() {
814814

815815
});
816816

817-
fdescribe('setTranslate', function() {
817+
describe('setTranslate', function() {
818818

819819
it('should work with regular DOM elements', function() {
820820
var el = document.createElement('div');

0 commit comments

Comments
 (0)