Skip to content

Commit

Permalink
Split function to satisfy codeclimate
Browse files Browse the repository at this point in the history
  • Loading branch information
danielgindi committed Aug 12, 2019
1 parent 7045059 commit 4312ec5
Showing 1 changed file with 45 additions and 37 deletions.
82 changes: 45 additions & 37 deletions src/helpers/helpers.rtl.js
@@ -1,43 +1,51 @@
'use strict';

var getRtlAdapter = function (rtl, rectX, width) {
var getRtlAdapter = function (rectX, width) {
return {
x: function (x) {
return rectX + rectX + width - x;
},
setWidth: function (w) {
width = w;
},
textAlign: function(align) {
if (align === 'center') return align;
return align === 'right' ? 'left' : 'right';
},
xPlus: function(x, value) {
return x - value;
},
leftForLtr: function(x, width) {
return x - width;
},
};
};

var getLtrAdapter = function () {
return {
x: function (x) {
return x;
},
setWidth: function (w) {
width = w;
},
textAlign: function(align) {
return align;
},
xPlus: function(x, value) {
return x + value;
},
leftForLtr: function(x, width) {
return x;
},
};
};

var getAdapter = function (rtl, rectX, width) {
if (rtl) {
return {
x: function (x) {
return rectX + rectX + width - x;
},
setWidth: function (w) {
width = w;
},
textAlign: function(align) {
if (align === 'center') return align;
return align === 'right' ? 'left' : 'right';
},
xPlus: function(x, value) {
return x - value;
},
leftForLtr: function(x, width) {
return x - width;
},
};
return getRtlAdapter(rectX, width);
} else {
return {
x: function (x) {
return x;
},
setWidth: function (w) {
width = w;
},
textAlign: function(align) {
return align;
},
xPlus: function(x, value) {
return x + value;
},
leftForLtr: function(x, width) {
return x;
},
};
return getLtrAdapter();
}
}

Expand Down Expand Up @@ -66,7 +74,7 @@ var restoreTextDirection = function(ctx) {
};

module.exports = {
getRtlAdapter: getRtlAdapter,
getRtlAdapter: getAdapter,
overrideTextDirection: overrideTextDirection,
restoreTextDirection: restoreTextDirection,
};

0 comments on commit 4312ec5

Please sign in to comment.