davatron5000 / FitText.js

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

Not listening for CSS changes and CSS transitions #105

Closed janheinrichmerker closed 9 years ago

janheinrichmerker commented 10 years ago

Text size not updating when width is changing in CSS Example: http://cdpn.io/ImrcJ (hover over the blue box to see the effect)

charliewilco commented 10 years ago

i think i have a good fix for you

call the resizer inside on the parent element:

$('#containing-element').on('resize.fittext orientationchange.fittext', resizer);

just inside the closing curly braces of the function started on line 15

should do the trick for you.

davatron5000 commented 9 years ago

The best we could do with JavaScript is listen for the transitionend event when the transition is over.

http://codepen.io/davatron5000/pen/bNdRwa

$('div').on('transitionend', function(){ $(document).trigger('resize'); });

For me, this is a subpar effect and I wouldn't want to build that behavior in. I'd probably recommend using plain ol' CSS transform: scale(1.5). I added a div.scale demo to my fork of the CodePen.