davatron5000 / FitText.js

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

I've tweaked the event attachment so you are able to stop FitText from firing without removing the window resize event. #28

Closed replete closed 10 years ago

federicovezzoli commented 11 years ago

Sorry, I do not understand how to call the off event to disable fittext. Anyone can help me?

davatron5000 commented 10 years ago

A resize.fittext event was added in 57ce345437f9b1871ece163a15954595a6e02b1e This probably solves the functionality of your use case. Thanks for you commit.

@federicovezzoli You can disable fittext with:

$('.myelems').off('resize.fittext orientationchange.fittext');
federicovezzoli commented 10 years ago

hey @davatron5000 thanks for the tip. But If I remove the handler on the element is not working, it works if I remove it from the window element. so, it works only with:

$(window).off('resize.fittext orientationchange.fittext');

Is there any way to disable it only on some selectors, like in the example you gave?

davatron5000 commented 10 years ago

Hmm... sounds like you're trying to use window.resize to trigger a window.resize. In that case, I'd probably go a different route and hijack fittext's resize instead.

$(window).on('resize.fittext', function(){
  var mediaQuery = '(max-width: 480px)';
  if(window.matchMedia(mediaQuery).matches) {
    $('h1.fixedFontSizeOnMobile').css('font-size', '36px');
  }
});

Anyways, this is personal support stuff for your specific implementation and not relevant to bugs, issues, or functionality to this plugin. I recommend asking your questions over on StackOverflow. Thanks.

federicovezzoli commented 10 years ago

Sorry than.