forked from roots/sage
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added fittext script for the hero region title.
- Loading branch information
Showing
3 changed files
with
76 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/*global jQuery */ | ||
/*! | ||
* FitText.js 1.1 | ||
* | ||
* Copyright 2011, Dave Rupert http://daverupert.com | ||
* Released under the WTFPL license | ||
* http://sam.zoy.org/wtfpl/ | ||
* | ||
* Date: Thu May 05 14:23:00 2011 -0600 | ||
*/ | ||
|
||
(function( $ ){ | ||
|
||
$.fn.fitText = function( kompressor, options ) { | ||
|
||
// Setup options | ||
var compressor = kompressor || 1, | ||
settings = $.extend({ | ||
'minFontSize' : Number.NEGATIVE_INFINITY, | ||
'maxFontSize' : Number.POSITIVE_INFINITY | ||
}, options); | ||
|
||
return this.each(function(){ | ||
|
||
// Store the object | ||
var $this = $(this); | ||
|
||
// Resizer() resizes items based on the object width divided by the compressor * 10 | ||
var resizer = function () { | ||
$this.css('font-size', Math.max(Math.min($this.width() / (compressor*10), parseFloat(settings.maxFontSize)), parseFloat(settings.minFontSize))); | ||
}; | ||
|
||
// Call once to set. | ||
resizer(); | ||
|
||
// Call on resize. Opera debounces their resize by default. | ||
$(window).on('resize', resizer); | ||
|
||
}); | ||
|
||
}; | ||
|
||
})( jQuery ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters