Skip to content

Instantly share code, notes, and snippets.

@DoronShapiro
DoronShapiro / jquery.textfill.js
Last active December 11, 2015 08:09
Modified to fill either width or height
(function($) {
$.fn.textfill = function(percentMax, direction) {
percentMax = parseFloat(percentMax);
return this.each(function(){
var ourText = $("span", this),
parent = ourText.parent(),
maxHeight = parent.height(),
maxWidth = parent.width(),
fontSize = parseInt(ourText.css("fontSize"), 10),
multiplier = (direction == "width") ?