From bb2999b4eefcde91d256189ae866fa0d0be11d72 Mon Sep 17 00:00:00 2001 From: Ivan Malopinsky Date: Sun, 1 Feb 2015 19:37:03 -0500 Subject: [PATCH] update textSize function to be more readable --- src/holder.js | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/holder.js b/src/holder.js index fc06aa5..9dfe30b 100644 --- a/src/holder.js +++ b/src/holder.js @@ -782,13 +782,14 @@ Holder.js - client side image placeholders * @param fontSize Requested text size */ function textSize(width, height, fontSize) { - height = parseInt(height, 10); - width = parseInt(width, 10); - var bigSide = Math.max(height, width); - var smallSide = Math.min(height, width); - var scale = App.defaults.scale; - var newHeight = Math.min(smallSide * 0.75, 0.75 * bigSide * scale); - return Math.abs(Math.round(Math.max(fontSize, newHeight))); + var stageWidth = parseInt(width, 10); + var stageHeight = parseInt(height, 10); + + var bigSide = Math.max(stageWidth, stageHeight); + var smallSide = Math.min(stageWidth, stageHeight); + + var newHeight = 0.8 * Math.min(smallSide, bigSide * App.defaults.scale); + return Math.round(Math.max(fontSize, newHeight)); } /**