davatron5000 / FitText.js

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

Update jquery.fittext.js to accept classes #124

Closed opanitch closed 9 years ago

opanitch commented 9 years ago

Updated the code to allow the use of class names (and thus, multiple items) to have fitText applied at once

opanitch commented 9 years ago

my instantiation call uses classes - $("h2.projTitle").fitText(1.2);

So I apply the same fitText rules to all h2 elements with class projTitle rather than just 1

opanitch commented 9 years ago

ah, i see why you asked - it does seem like a silly update, but the function did not work on my elements in the original implementation. Not really sure what makes these changes special, but it works. See http://staging.anatomidesign.com/jbd/#portfolio for an example

davatron5000 commented 9 years ago

Can you supply a reduced test case of FitText not working on multiple elements using a class selector? It should totally do that already.

On Sat, Nov 15, 2014 at 11:00 AM, Oren notifications@github.com wrote:

my instantiation call uses classes - $("h2.projTitle").fitText(1.2);

So I apply the same fitText rules to all h2 elements with class projTitle rather than just 1

Reply to this email directly or view it on GitHub: https://github.com/davatron5000/FitText.js/pull/124#issuecomment-63179289

opanitch commented 9 years ago

I figured out what it was - I had to alter the the parent that the script pulled the width from because the object it was sitting in was initially a constricted width that would then animate open. It didn't resize after the animation. You can delete this pull request, but possibly open an issue about css animations/on object resize?

davatron5000 commented 9 years ago

If an element doesn't have width we can't calculate the fluid width. You'd have to $(window).trigger('resize.fittext') when you animate the parent div open. 

Glad to hear it's working for you!

On Sat, Nov 15, 2014 at 12:50 PM, Oren notifications@github.com wrote:

I figured out what it was - I had to alter the the parent that the script pulled the width from because the object it was sitting in was initially a constricted width that would then animate open. It didn't resize after the animation. You can delete this pull request, but possibly open an issue about css animations/on object resize?

Reply to this email directly or view it on GitHub: https://github.com/davatron5000/FitText.js/pull/124#issuecomment-63183407

opanitch commented 9 years ago

ah good tip, thanks!