davatron5000 / FitText.js

A jQuery plugin for inflating web type
http://fittextjs.com
6.75k stars 1.39k forks source link

Font size cached? #41

Closed bartveneman closed 12 years ago

bartveneman commented 12 years ago

I'm using fittext on all my hgroup h1's. On the homepage it works like a charm, however, the calculated font size seems to be used across all pages that use this pattern. The css is like this:

hgroup h1 {
    display: block;
    width: 100%;
}

And the js:

$(document).ready(function () {
    'use strict';
    $("hgroup h1").fitText(1.1);
});

As I said: it looks like the value is calculated only once and this value is cached and used in other pages. Am I doing something wrong, or is there a solution to this?

bartveneman commented 12 years ago

Is it possible that font-size is shared across pages because they're all applied to the same element, but with different content? For example: if I would give all hgroup h1's a unique ID, would in work?

davatron5000 commented 12 years ago

The font-size shouldn't be cached. It's executed after ever page load.

Maybe there's some confusion on how FitText works. It's ratio based resizing so the font size is determined by the parent element's width.

fitText(1.1) would be 1/11th of the width of the container. so if your parent container (column of text) is 550px wide, the font size would be 50px.

Does that help?

bartveneman commented 12 years ago

That does the trick. I was indeed confused by the compressor worked. That's solved now, thank you very much.