From 42e10d16dcf9a8e92552f1b502b085d534c22d06 Mon Sep 17 00:00:00 2001 From: Dave Riess Date: Mon, 25 May 2015 18:56:01 -0600 Subject: [PATCH 1/2] Bug fix - maxfontsize logic interferes with debounce overshoot --- dist/bigtext.js | 4 ++-- dist/test/tests.js | 13 +++++++++++++ src/bigtext-test.js | 13 +++++++++++++ src/bigtext.js | 2 +- 4 files changed, 29 insertions(+), 3 deletions(-) diff --git a/dist/bigtext.js b/dist/bigtext.js index 16a99ba..e492420 100644 --- a/dist/bigtext.js +++ b/dist/bigtext.js @@ -1,4 +1,4 @@ -/*! BigText - v0.1.8 - 2015-02-28 +/*! BigText - v0.1.8 - 2015-05-25 * https://github.com/zachleat/bigtext * Copyright (c) 2015 Zach Leatherman (@zachleat) * MIT License */ @@ -215,7 +215,7 @@ outer: for(var m=0, n=intervals.length; m maxFontSize) { + if(newFontSize + j*intervals[m] - 10 > maxFontSize) { newFontSize = maxFontSize; break outer; } diff --git a/dist/test/tests.js b/dist/test/tests.js index d200921..ece267e 100644 --- a/dist/test/tests.js +++ b/dist/test/tests.js @@ -187,6 +187,19 @@ 'Font size should equal the maximum.'); }); + test('testCloseToMaxFontSize', function() + { + $('#qunit-fixture').html('
Hello
'); + $('#test').bigtext(); + var font_size_without_max = $('#test > div').css('font-size'); + + $('#test').bigtext( { maxfontsize: parseInt(font_size_without_max)+1 } ); + var font_size_with_max = $('#test > div').css('font-size'); + + equal(font_size_with_max, font_size_without_max, + 'Font size should equal the maximum.'); + }); + test('testUnbrokenSingleWord', function() { $('#qunit-fixture').html('
This
'); diff --git a/src/bigtext-test.js b/src/bigtext-test.js index ef5d2d1..3d0c923 100644 --- a/src/bigtext-test.js +++ b/src/bigtext-test.js @@ -188,6 +188,19 @@ 'Font size should equal the maximum.'); }); + test('testCloseToMaxFontSize', function() + { + $('#qunit-fixture').html('
Hello
'); + $('#test').bigtext(); + var font_size_without_max = $('#test > div').css('font-size'); + + $('#test').bigtext( { maxfontsize: parseInt(font_size_without_max)+1 } ); + var font_size_with_max = $('#test > div').css('font-size'); + + equal(font_size_with_max, font_size_without_max, + 'Font size should equal the maximum.'); + }); + test('testUnbrokenSingleWord', function() { $('#qunit-fixture').html('
This
'); diff --git a/src/bigtext.js b/src/bigtext.js index 33597f0..e4eb72f 100644 --- a/src/bigtext.js +++ b/src/bigtext.js @@ -210,7 +210,7 @@ outer: for(var m=0, n=intervals.length; m maxFontSize) { + if(newFontSize + j*intervals[m] - 10 > maxFontSize) { newFontSize = maxFontSize; break outer; } From 89262bd2006d7e74af0949221e4140091dc5c0bc Mon Sep 17 00:00:00 2001 From: Dave Riess Date: Mon, 25 May 2015 18:57:56 -0600 Subject: [PATCH 2/2] fix test description --- dist/test/tests.js | 2 +- src/bigtext-test.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dist/test/tests.js b/dist/test/tests.js index ece267e..eba73c8 100644 --- a/dist/test/tests.js +++ b/dist/test/tests.js @@ -197,7 +197,7 @@ var font_size_with_max = $('#test > div').css('font-size'); equal(font_size_with_max, font_size_without_max, - 'Font size should equal the maximum.'); + 'Font size should not equal the maximum.'); }); test('testUnbrokenSingleWord', function() diff --git a/src/bigtext-test.js b/src/bigtext-test.js index 3d0c923..169d63f 100644 --- a/src/bigtext-test.js +++ b/src/bigtext-test.js @@ -198,7 +198,7 @@ var font_size_with_max = $('#test > div').css('font-size'); equal(font_size_with_max, font_size_without_max, - 'Font size should equal the maximum.'); + 'Font size should not equal the maximum.'); }); test('testUnbrokenSingleWord', function()