Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript FitText.js not working?

  • This topic is empty.
Viewing 15 posts - 1 through 15 (of 15 total)
  • Author
    Posts
  • #154976
    chrisburton
    Participant

    I can’t get this guy to work to save my life. I feel like it’s something really really simple that I’m not seeing.

    http://chrisburton.me/webtype.

    #154977
    Alen
    Participant

    It works for me in DevTools.

    You’re missing ; at the end of fitText()

    #154978
    chrisburton
    Participant

    The semicolon is not needed according to the source code. However, it doesn’t seem to work. My text is not resizing to fit the width of the container.

    #154979
    Alen
    Participant
    #154980
    chrisburton
    Participant

    I had to set it as .31 in the script. It works now. Thanks!

    #154981
    Alen
    Participant

    Why .31, seems like a very random number.

    I thought fitText(); would do that auto-magically, without passing anything.

    #154982
    chrisburton
    Participant

    I’m not sure why but it states this in the docs.

    If your text is resizing poorly, you’ll want to turn tweak up/down “The Compressor”. It works a little like a guitar amp. The default is 1.

    #154983
    Alen
    Participant

    I just confirmed this on my local machine. fitText(); should just work.

    css …

    .wrapper { width:800px; }
    

    html

    <div class="wrapper">
    <h1 class="h1">My fitText title</h1>
    </div>
    

    script

    $('.h1').fitText();
    
    #154985
    Alen
    Participant

    #154986
    Alen
    Participant

    Could it be that you’re using it on p instead of h1 etc…?

    #154987
    chrisburton
    Participant

    I don’t think so. In the demo, they are using spans and it still works without setting the ‘Compressor’.

    #154988
    chrisburton
    Participant
    #154989
    Alen
    Participant

    Yeah I’m not fond of fitText so not much experience with it. Including JavaScript lib just to make text bigger, idk… much rather control it with CSS.

    http://vimeo.com/68910118 start at 31 mark Remy has a great point about the library.

    #154991
    chrisburton
    Participant

    Awesome. I wonder what the Paravel team had to say about it.

    #253358
    Aventura5
    Participant

    Well I figured out what was happening with my code. Turns out you haveto call fittext at the botom of the page, after the text has loaded. otherwise the heading doesn’t actually exist when jQuery looks for it.

Viewing 15 posts - 1 through 15 (of 15 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.