]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
Simplify rtlAdapter export (#7120)
authorBen McCann <322311+benmccann@users.noreply.github.com>
Wed, 19 Feb 2020 19:20:11 +0000 (11:20 -0800)
committerGitHub <noreply@github.com>
Wed, 19 Feb 2020 19:20:11 +0000 (14:20 -0500)
src/helpers/helpers.rtl.js

index 45fd64cf3acd55f08a53ae98277b246a45fbfec6..5b0d2cda61ed17476019d2812b64798b27aad053 100644 (file)
@@ -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
-};
+}