Skip to content

Add underscore resize debouncer #42

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Dec 27, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion bigtext.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@
if($.fn.smartresize) {
// https://github.com/lrbabe/jquery-smartresize/
eventName = 'smartresize.' + eventName;
} else if(_.debounce) {
resizeFunction = _.debounce(resizeFunction, 200)
}
$(window).unbind(eventName).bind(eventName, resizeFunction);
}
Expand Down Expand Up @@ -95,7 +97,7 @@
resize: true
}, options || {});

return this.each(function()
this.each(function()
{
var $t = $(this).addClass('bigtext'),
maxWidth = $t.width(),
Expand Down Expand Up @@ -127,6 +129,7 @@
var sizes = calculateSizes($t, $children, maxWidth, options.maxfontsize, options.minfontsize);
$headCache.append(BigText.generateCss(id, sizes.fontSizes, sizes.wordSpacings, sizes.minFontSizes));
});
return this.trigger('bigtext:complete')
}
};

Expand Down
5 changes: 5 additions & 0 deletions test/lib/underscore-1.5.2.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion test/test.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
<script src="http://code.jquery.com/jquery-1.10.2.js"></script>
<script src="lib/jquery-partial-migrate.js"></script>
<script src="lib/qunit-1.12.0.js"></script>
<script src="lib/underscore-1.5.2.js"></script>
<script src="../bigtext.js"></script>
<script src="bigtextTest.js"></script>
</body>
</html>
</html>