diff --git a/clamp.js b/clamp.js index f13e8ad..89f6cb9 100644 --- a/clamp.js +++ b/clamp.js @@ -86,7 +86,7 @@ */ function getMaxHeight(clmp) { var lineHeight = getLineHeight(element); - return lineHeight * clmp; + return Math.ceil(lineHeight * clmp); } /** @@ -97,9 +97,9 @@ if (lh == 'normal') { // Normal line heights vary from browser to browser. The spec recommends // a value between 1.0 and 1.2 of the font size. Using 1.1 to split the diff. - lh = parseInt(computeStyle(elem, 'font-size')) * 1.2; + lh = parseFloat(computeStyle(elem, 'font-size')) * 1.2; } - return parseInt(lh); + return parseFloat(lh); } @@ -258,4 +258,4 @@ } window.$clamp = clamp; -})(); \ No newline at end of file +})(); diff --git a/clamp.min.js b/clamp.min.js index 2d8783a..fcf37e0 100644 --- a/clamp.min.js +++ b/clamp.min.js @@ -5,8 +5,8 @@ * Released under the WTFPL license * http://sam.zoy.org/wtfpl/ */ -(function(){window.$clamp=function(c,d){function s(a,b){n.getComputedStyle||(n.getComputedStyle=function(a,b){this.el=a;this.getPropertyValue=function(b){var c=/(\-([a-z]){1})/g;"float"==b&&(b="styleFloat");c.test(b)&&(b=b.replace(c,function(a,b,c){return c.toUpperCase()}));return a.currentStyle&&a.currentStyle[b]?a.currentStyle[b]:null};return this});return n.getComputedStyle(a,null).getPropertyValue(b)}function t(a){a=a||c.clientHeight;var b=u(c);return Math.max(Math.floor(a/b),0)}function x(a){return u(c)* -a}function u(a){var b=s(a,"line-height");"normal"==b&&(b=1.2*parseInt(s(a,"font-size")));return parseInt(b)}function l(a){if(a.lastChild.children&&0