From 10c3c3bbc9dfdf18a817f7a48acba1a334e39632 Mon Sep 17 00:00:00 2001 From: Ben McCann <322311+benmccann@users.noreply.github.com> Date: Wed, 19 Feb 2020 11:20:11 -0800 Subject: [PATCH] Simplify rtlAdapter export (#7120) --- src/helpers/helpers.rtl.js | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/src/helpers/helpers.rtl.js b/src/helpers/helpers.rtl.js index 45fd64cf3..5b0d2cda6 100644 --- a/src/helpers/helpers.rtl.js +++ b/src/helpers/helpers.rtl.js @@ -1,4 +1,4 @@ -const getRtlAdapter = function(rectX, width) { +const getRightToLeftAdapter = function(rectX, width) { return { x(x) { return rectX + rectX + width - x; @@ -21,7 +21,7 @@ const getRtlAdapter = function(rectX, width) { }; }; -const getLtrAdapter = function() { +const getLeftToRightAdapter = function() { return { x(x) { return x; @@ -40,11 +40,11 @@ const getLtrAdapter = function() { }; }; -const getAdapter = function(rtl, rectX, width) { - return rtl ? getRtlAdapter(rectX, width) : getLtrAdapter(); -}; +export function getRtlAdapter(rtl, rectX, width) { + return rtl ? getRightToLeftAdapter(rectX, width) : getLeftToRightAdapter(); +} -const overrideTextDirection = function(ctx, direction) { +export function overrideTextDirection(ctx, direction) { let style, original; if (direction === 'ltr' || direction === 'rtl') { style = ctx.canvas.style; @@ -56,17 +56,11 @@ const overrideTextDirection = function(ctx, direction) { style.setProperty('direction', direction, 'important'); ctx.prevTextDirection = original; } -}; +} -const restoreTextDirection = function(ctx, original) { +export function restoreTextDirection(ctx, original) { if (original !== undefined) { delete ctx.prevTextDirection; ctx.canvas.style.setProperty('direction', original[0], original[1]); } -}; - -export { - getAdapter as getRtlAdapter, - overrideTextDirection, - restoreTextDirection -}; +} -- 2.47.2