From fedda5b6c65ebd0a87670e90f15d130a31887965 Mon Sep 17 00:00:00 2001 From: andi-b Date: Fri, 9 Feb 2018 10:19:07 +0000 Subject: [PATCH] Added variables and made function private Added variable for clientWidth and clientHeight; Made function calculatePadding private --- src/core/core.helpers.js | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/core/core.helpers.js b/src/core/core.helpers.js index 8e0de61b7e1..38bbb1da14e 100644 --- a/src/core/core.helpers.js +++ b/src/core/core.helpers.js @@ -466,7 +466,10 @@ module.exports = function(Chart) { helpers.getConstraintHeight = function(domNode) { return getConstraintDimension(domNode, 'max-height', 'clientHeight'); }; - helpers.calculatePadding = function(container, padding, parentDimension) { + /** + * @private + */ + helpers._calculatePadding = function(container, padding, parentDimension) { padding = helpers.getStyle(container, padding); return padding.indexOf('%') > -1 ? parentDimension / parseInt(padding, 10) : parseInt(padding, 10); @@ -477,10 +480,11 @@ module.exports = function(Chart) { return domNode.clientWidth; } - var paddingLeft = helpers.calculatePadding(container, 'padding-left', container.clientWidth); - var paddingRight = helpers.calculatePadding(container, 'padding-right', container.clientWidth); + var clientWidth = container.clientWidth; + var paddingLeft = helpers._calculatePadding(container, 'padding-left', clientWidth); + var paddingRight = helpers._calculatePadding(container, 'padding-right', clientWidth); - var w = container.clientWidth - paddingLeft - paddingRight; + var w = clientWidth - paddingLeft - paddingRight; var cw = helpers.getConstraintWidth(domNode); return isNaN(cw) ? w : Math.min(w, cw); }; @@ -490,10 +494,11 @@ module.exports = function(Chart) { return domNode.clientHeight; } - var paddingTop = helpers.calculatePadding(container, 'padding-top', container.clientHeight); - var paddingBottom = helpers.calculatePadding(container, 'padding-bottom', container.clientHeight); + var clientHeight = container.clientHeight; + var paddingTop = helpers._calculatePadding(container, 'padding-top', clientHeight); + var paddingBottom = helpers._calculatePadding(container, 'padding-bottom', clientHeight); - var h = container.clientHeight - paddingTop - paddingBottom; + var h = clientHeight - paddingTop - paddingBottom; var ch = helpers.getConstraintHeight(domNode); return isNaN(ch) ? h : Math.min(h, ch); };